viem 0.2.0-jxom-local-accounts.20230321T212822 → 0.2.0-jxom-local-accounts.20230327T004031

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 (71) hide show
  1. package/dist/abi.d.ts +3 -3
  2. package/dist/abi.js +2 -2
  3. package/dist/abi.mjs +1 -1
  4. package/dist/accounts/index.d.ts +62 -5
  5. package/dist/accounts/index.js +79 -16
  6. package/dist/accounts/index.js.map +1 -1
  7. package/dist/accounts/index.mjs +74 -11
  8. package/dist/accounts/index.mjs.map +1 -1
  9. package/dist/{chain-f8db473f.d.ts → chain-40443542.d.ts} +1 -1
  10. package/dist/{chain-75b0942e.d.ts → chain-4af995bf.d.ts} +63 -27
  11. package/dist/chains.d.ts +3 -3
  12. package/dist/chains.js +63 -63
  13. package/dist/chains.mjs +1 -1
  14. package/dist/{chunk-NJSAEA2H.js → chunk-CGTZNR2R.js} +507 -3
  15. package/dist/chunk-CGTZNR2R.js.map +1 -0
  16. package/dist/{chunk-IVRML3IK.mjs → chunk-HWVZ6VEQ.mjs} +506 -2
  17. package/dist/chunk-HWVZ6VEQ.mjs.map +1 -0
  18. package/dist/{chunk-FNVFGFWN.mjs → chunk-PVK5TA2L.mjs} +2 -2
  19. package/dist/chunk-PVK5TA2L.mjs.map +1 -0
  20. package/dist/{chunk-6UKHPIXX.mjs → chunk-UCNDS4FE.mjs} +2 -2
  21. package/dist/chunk-UCNDS4FE.mjs.map +1 -0
  22. package/dist/{chunk-LYQKHD7R.js → chunk-VSAG2LPH.js} +19 -19
  23. package/dist/chunk-VSAG2LPH.js.map +1 -0
  24. package/dist/{chunk-FQM5MF6U.js → chunk-XLIQDCZW.js} +6 -6
  25. package/dist/chunk-XLIQDCZW.js.map +1 -0
  26. package/dist/contract.d.ts +8 -8
  27. package/dist/contract.js +2 -2
  28. package/dist/contract.mjs +1 -1
  29. package/dist/{createClient-f87255c1.d.ts → createClient-1f19be8d.d.ts} +23 -9
  30. package/dist/{createPublicClient-d2c37c92.d.ts → createPublicClient-b53e3c3d.d.ts} +116 -116
  31. package/dist/{eip1193-ae706fd8.d.ts → eip1193-210ab776.d.ts} +1 -1
  32. package/dist/{encodeFunctionResult-4792a6a3.d.ts → encodeFunctionResult-a252fba1.d.ts} +1 -1
  33. package/dist/{encodePacked-3fcdd54b.d.ts → encodePacked-a9464e97.d.ts} +1 -1
  34. package/dist/ens.d.ts +5 -5
  35. package/dist/ens.js +3 -3
  36. package/dist/ens.mjs +2 -2
  37. package/dist/ethers.d.ts +3 -3
  38. package/dist/ethers.js +4 -4
  39. package/dist/ethers.mjs +2 -2
  40. package/dist/{formatAbiItem-765ebc53.d.ts → formatAbiItem-6ed70dbd.d.ts} +1 -1
  41. package/dist/{getAbiItem-693e6e1b.d.ts → getAbiItem-1ff0f41a.d.ts} +1 -1
  42. package/dist/index.d.ts +21 -15
  43. package/dist/index.js +127 -102
  44. package/dist/index.js.map +1 -1
  45. package/dist/index.mjs +67 -42
  46. package/dist/index.mjs.map +1 -1
  47. package/dist/{parseAccount-2d7ea01d.d.ts → parseAccount-8e131c73.d.ts} +1 -1
  48. package/dist/{parseGwei-377678bc.d.ts → parseGwei-b3a175f7.d.ts} +51 -7
  49. package/dist/public.d.ts +5 -5
  50. package/dist/public.js +2 -2
  51. package/dist/public.mjs +1 -1
  52. package/dist/test-e28db435.d.ts +198 -0
  53. package/dist/test.d.ts +11 -11
  54. package/dist/test.js +2 -2
  55. package/dist/test.mjs +1 -1
  56. package/dist/{typedData-ade018d6.d.ts → typedData-848139b1.d.ts} +11 -11
  57. package/dist/utils/index.d.ts +16 -36
  58. package/dist/utils/index.js +18 -2
  59. package/dist/utils/index.mjs +17 -1
  60. package/dist/wallet.d.ts +5 -5
  61. package/dist/wallet.js +2 -2
  62. package/dist/wallet.mjs +1 -1
  63. package/dist/window.d.ts +2 -2
  64. package/package.json +1 -1
  65. package/dist/chunk-6UKHPIXX.mjs.map +0 -1
  66. package/dist/chunk-FNVFGFWN.mjs.map +0 -1
  67. package/dist/chunk-FQM5MF6U.js.map +0 -1
  68. package/dist/chunk-IVRML3IK.mjs.map +0 -1
  69. package/dist/chunk-LYQKHD7R.js.map +0 -1
  70. package/dist/chunk-NJSAEA2H.js.map +0 -1
  71. package/dist/test-98c0b642.d.ts +0 -206
package/dist/abi.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { ParseAbi, ParseAbiItem, ParseAbiParameter, ParseAbiParameters, parseAbi, parseAbiItem, parseAbiParameter, parseAbiParameters } from 'abitype';
2
- export { D as DecodeAbiParametersReturnType, E as EncodeAbiParametersReturnType, G as GetAbiItemParameters, d as decodeAbiParameters, e as encodeAbiParameters, g as getAbiItem } from './getAbiItem-693e6e1b.js';
3
- export { e as encodePacked } from './encodePacked-3fcdd54b.js';
4
- import './chain-75b0942e.js';
2
+ export { D as DecodeAbiParametersReturnType, E as EncodeAbiParametersReturnType, G as GetAbiItemParameters, d as decodeAbiParameters, e as encodeAbiParameters, g as getAbiItem } from './getAbiItem-1ff0f41a.js';
3
+ export { e as encodePacked } from './encodePacked-a9464e97.js';
4
+ import './chain-4af995bf.js';
5
5
  import '@wagmi/chains';
package/dist/abi.js CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
 
9
9
 
10
- var _chunkNJSAEA2Hjs = require('./chunk-NJSAEA2H.js');
10
+ var _chunkCGTZNR2Rjs = require('./chunk-CGTZNR2R.js');
11
11
 
12
12
 
13
13
 
@@ -17,5 +17,5 @@ var _chunkNJSAEA2Hjs = require('./chunk-NJSAEA2H.js');
17
17
 
18
18
 
19
19
 
20
- exports.decodeAbiParameters = _chunkNJSAEA2Hjs.decodeAbiParameters; exports.encodeAbiParameters = _chunkNJSAEA2Hjs.encodeAbiParameters; exports.encodePacked = _chunkNJSAEA2Hjs.encodePacked; exports.getAbiItem = _chunkNJSAEA2Hjs.getAbiItem; exports.parseAbi = _chunkNJSAEA2Hjs.parseAbi; exports.parseAbiItem = _chunkNJSAEA2Hjs.parseAbiItem; exports.parseAbiParameter = _chunkNJSAEA2Hjs.parseAbiParameter; exports.parseAbiParameters = _chunkNJSAEA2Hjs.parseAbiParameters;
20
+ exports.decodeAbiParameters = _chunkCGTZNR2Rjs.decodeAbiParameters; exports.encodeAbiParameters = _chunkCGTZNR2Rjs.encodeAbiParameters; exports.encodePacked = _chunkCGTZNR2Rjs.encodePacked; exports.getAbiItem = _chunkCGTZNR2Rjs.getAbiItem; exports.parseAbi = _chunkCGTZNR2Rjs.parseAbi; exports.parseAbiItem = _chunkCGTZNR2Rjs.parseAbiItem; exports.parseAbiParameter = _chunkCGTZNR2Rjs.parseAbiParameter; exports.parseAbiParameters = _chunkCGTZNR2Rjs.parseAbiParameters;
21
21
  //# sourceMappingURL=abi.js.map
package/dist/abi.mjs CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  parseAbiItem,
8
8
  parseAbiParameter,
9
9
  parseAbiParameters
10
- } from "./chunk-IVRML3IK.mjs";
10
+ } from "./chunk-HWVZ6VEQ.mjs";
11
11
  export {
12
12
  decodeAbiParameters,
13
13
  encodeAbiParameters,
@@ -1,33 +1,90 @@
1
1
  export { HDKey } from '@scure/bip32';
2
- import { P as PrivateKeyAccount, a as AccountSource, J as JsonRpcAccount, C as CustomSource, L as LocalAccount, T as TypedDataDefinition } from '../typedData-ade018d6.js';
3
- export { A as Account, a as AccountSource, C as CustomSource, H as HDAccount, b as HDOptions, J as JsonRpcAccount, L as LocalAccount, P as PrivateKeyAccount } from '../typedData-ade018d6.js';
4
- import { H as Hex } from '../chain-75b0942e.js';
2
+ import { H as Hex } from '../chain-4af995bf.js';
3
+ import { P as PrivateKeyAccount, a as AccountSource, J as JsonRpcAccount, C as CustomSource, L as LocalAccount, T as TypedDataDefinition } from '../typedData-848139b1.js';
4
+ export { A as Account, a as AccountSource, C as CustomSource, H as HDAccount, b as HDOptions, J as JsonRpcAccount, L as LocalAccount, P as PrivateKeyAccount } from '../typedData-848139b1.js';
5
5
  import { Address, TypedData } from 'abitype';
6
- export { p as parseAccount } from '../parseAccount-2d7ea01d.js';
6
+ export { p as parseAccount } from '../parseAccount-8e131c73.js';
7
+ export { wordlist as czech } from '@scure/bip39/wordlists/czech';
8
+ export { wordlist as english } from '@scure/bip39/wordlists/english';
9
+ export { wordlist as french } from '@scure/bip39/wordlists/french';
10
+ export { wordlist as italian } from '@scure/bip39/wordlists/italian';
11
+ export { wordlist as japanese } from '@scure/bip39/wordlists/japanese';
12
+ export { wordlist as korean } from '@scure/bip39/wordlists/korean';
13
+ export { wordlist as simplifiedChinese } from '@scure/bip39/wordlists/simplified-chinese';
14
+ export { wordlist as spanish } from '@scure/bip39/wordlists/spanish';
15
+ export { wordlist as traditionalChinese } from '@scure/bip39/wordlists/traditional-chinese';
7
16
  import '@wagmi/chains';
8
17
 
18
+ /**
19
+ * @description Generates a random mnemonic phrase with a given wordlist.
20
+ *
21
+ * @param wordlist The wordlist to use for generating the mnemonic phrase.
22
+ *
23
+ * @returns A randomly generated mnemonic phrase.
24
+ */
25
+ declare function generateMnemonic(wordlist: string[]): string;
26
+
27
+ /**
28
+ * @description Generates a random private key.
29
+ *
30
+ * @returns A randomly generated private key.
31
+ */
32
+ declare function generatePrivateKey(): Hex;
33
+
34
+ /**
35
+ * @description Creates an Account from a private key.
36
+ *
37
+ * @returns A Private Key Account.
38
+ */
9
39
  declare function privateKeyToAccount(privateKey: Hex): PrivateKeyAccount;
10
40
 
11
41
  type GetAccountReturnType<TAccountSource extends AccountSource> = (TAccountSource extends Address ? JsonRpcAccount : never) | (TAccountSource extends CustomSource ? LocalAccount : never);
42
+ /**
43
+ * @description Creates an Account from a custom signing implementation.
44
+ *
45
+ * @returns A Local Account.
46
+ */
12
47
  declare function toAccount<TAccountSource extends AccountSource>(source: TAccountSource): GetAccountReturnType<TAccountSource>;
13
48
 
49
+ /**
50
+ * @description Converts an ECDSA public key to an address.
51
+ *
52
+ * @param publicKey The public key to convert.
53
+ *
54
+ * @returns The address.
55
+ */
14
56
  declare function publicKeyToAddress(publicKey: Hex): Address;
15
57
 
16
58
  type SignMessageParameters = {
59
+ /** The message to sign. */
17
60
  message: string;
61
+ /** The private key to sign with. */
18
62
  privateKey: Hex;
19
63
  };
20
64
  type SignMessageReturnType = Hex;
65
+ /**
66
+ * @description Calculates an Ethereum-specific signature in [EIP-191 format](https://eips.ethereum.org/EIPS/eip-191):
67
+ * `keccak256("\x19Ethereum Signed Message:\n" + len(message) + message))`.
68
+ *
69
+ * @returns The signature.
70
+ */
21
71
  declare function signMessage({ message, privateKey, }: SignMessageParameters): Promise<SignMessageReturnType>;
22
72
 
23
73
  type SignTypedDataParameters<TTypedData extends TypedData | {
24
74
  [key: string]: unknown;
25
75
  } = TypedData, TPrimaryType extends string = string> = TypedDataDefinition<TTypedData, TPrimaryType> & {
76
+ /** The private key to sign with. */
26
77
  privateKey: Hex;
27
78
  };
28
79
  type SignTypedDataReturnType = Hex;
80
+ /**
81
+ * @description Signs typed data and calculates an Ethereum-specific signature in [EIP-191 format](https://eips.ethereum.org/EIPS/eip-191):
82
+ * `keccak256("\x19Ethereum Signed Message:\n" + len(message) + message))`.
83
+ *
84
+ * @returns The signature.
85
+ */
29
86
  declare function signTypedData<TTypedData extends TypedData | {
30
87
  [key: string]: unknown;
31
88
  }, TPrimaryType extends string = string>({ privateKey, ...typedData }: SignTypedDataParameters<TTypedData, TPrimaryType>): Promise<SignTypedDataReturnType>;
32
89
 
33
- export { SignMessageParameters, SignMessageReturnType, SignTypedDataParameters, SignTypedDataReturnType, privateKeyToAccount, publicKeyToAddress, signMessage, signTypedData, toAccount };
90
+ export { SignMessageParameters, SignMessageReturnType, SignTypedDataParameters, SignTypedDataReturnType, generateMnemonic, generatePrivateKey, privateKeyToAccount, publicKeyToAddress, signMessage, signTypedData, toAccount };
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkFQM5MF6Ujs = require('../chunk-FQM5MF6U.js');
3
+ var _chunkXLIQDCZWjs = require('../chunk-XLIQDCZW.js');
4
4
 
5
5
 
6
6
 
@@ -8,18 +8,32 @@ var _chunkFQM5MF6Ujs = require('../chunk-FQM5MF6U.js');
8
8
 
9
9
 
10
10
 
11
- var _chunkNJSAEA2Hjs = require('../chunk-NJSAEA2H.js');
11
+
12
+
13
+ var _chunkCGTZNR2Rjs = require('../chunk-CGTZNR2R.js');
12
14
 
13
15
  // src/accounts/index.ts
14
16
  var _bip32 = require('@scure/bip32');
15
17
 
16
- // src/accounts/privateKeyToAccount.ts
18
+ // src/accounts/generateMnemonic.ts
19
+ var _bip39 = require('@scure/bip39');
20
+ function generateMnemonic(wordlist10) {
21
+ return _bip39.generateMnemonic.call(void 0, wordlist10);
22
+ }
23
+
24
+ // src/accounts/generatePrivateKey.ts
17
25
  var _secp256k1 = require('@noble/secp256k1');
26
+ function generatePrivateKey() {
27
+ return _chunkCGTZNR2Rjs.toHex.call(void 0, _secp256k1.utils.randomPrivateKey());
28
+ }
29
+
30
+ // src/accounts/privateKeyToAccount.ts
31
+
18
32
 
19
33
  // src/accounts/utils/publicKeyToAddress.ts
20
34
  function publicKeyToAddress(publicKey) {
21
- const address = _chunkNJSAEA2Hjs.keccak256.call(void 0, `0x${publicKey.substring(4)}`).substring(26);
22
- return _chunkNJSAEA2Hjs.checksumAddress.call(void 0, `0x${address}`);
35
+ const address = _chunkCGTZNR2Rjs.keccak256.call(void 0, `0x${publicKey.substring(4)}`).substring(26);
36
+ return _chunkCGTZNR2Rjs.checksumAddress.call(void 0, `0x${address}`);
23
37
  }
24
38
 
25
39
  // src/accounts/utils/sign.ts
@@ -28,11 +42,25 @@ async function sign({
28
42
  hash,
29
43
  privateKey
30
44
  }) {
31
- const [signature, recId] = await _secp256k1.sign.call(void 0, hash.slice(2), privateKey.slice(2), {
45
+ const [sigBytes, recId] = await _secp256k1.sign.call(void 0, hash.slice(2), privateKey.slice(2), {
32
46
  canonical: true,
33
47
  recovered: true
34
48
  });
35
- return `0x${_secp256k1.Signature.fromHex(signature).toCompactHex()}${recId ? "1c" : "1b"}`;
49
+ const sig = _secp256k1.Signature.fromHex(sigBytes);
50
+ return {
51
+ r: _chunkCGTZNR2Rjs.toHex.call(void 0, sig.r),
52
+ s: _chunkCGTZNR2Rjs.toHex.call(void 0, sig.s),
53
+ v: recId ? 28n : 27n
54
+ };
55
+ }
56
+
57
+ // src/accounts/utils/signatureToHex.ts
58
+
59
+ function signatureToHex({ r, s, v }) {
60
+ return `0x${new (0, _secp256k1.Signature)(
61
+ _chunkCGTZNR2Rjs.hexToBigInt.call(void 0, r),
62
+ _chunkCGTZNR2Rjs.hexToBigInt.call(void 0, s)
63
+ ).toCompactHex()}${_chunkCGTZNR2Rjs.toHex.call(void 0, v).slice(2)}`;
36
64
  }
37
65
 
38
66
  // src/accounts/utils/signMessage.ts
@@ -40,7 +68,20 @@ async function signMessage({
40
68
  message,
41
69
  privateKey
42
70
  }) {
43
- return sign({ hash: _chunkNJSAEA2Hjs.hashMessage.call(void 0, message), privateKey });
71
+ const signature = await sign({ hash: _chunkCGTZNR2Rjs.hashMessage.call(void 0, message), privateKey });
72
+ return signatureToHex(signature);
73
+ }
74
+
75
+ // src/accounts/utils/signTransaction.ts
76
+ async function signTransaction({
77
+ privateKey,
78
+ transaction
79
+ }) {
80
+ const signature = await sign({
81
+ hash: _chunkCGTZNR2Rjs.keccak256.call(void 0, _chunkCGTZNR2Rjs.serializeTransaction.call(void 0, transaction)),
82
+ privateKey
83
+ });
84
+ return _chunkCGTZNR2Rjs.serializeTransaction.call(void 0, transaction, signature);
44
85
  }
45
86
 
46
87
  // src/accounts/utils/signTypedData.ts
@@ -48,23 +89,24 @@ async function signTypedData({
48
89
  privateKey,
49
90
  ...typedData
50
91
  }) {
51
- return sign({
52
- hash: _chunkNJSAEA2Hjs.hashTypedData.call(void 0, typedData),
92
+ const signature = await sign({
93
+ hash: _chunkCGTZNR2Rjs.hashTypedData.call(void 0, typedData),
53
94
  privateKey
54
95
  });
96
+ return signatureToHex(signature);
55
97
  }
56
98
 
57
99
  // src/accounts/privateKeyToAccount.ts
58
100
  function privateKeyToAccount(privateKey) {
59
- const publicKey = _chunkNJSAEA2Hjs.toHex.call(void 0, _secp256k1.getPublicKey.call(void 0, privateKey.slice(2)));
101
+ const publicKey = _chunkCGTZNR2Rjs.toHex.call(void 0, _secp256k1.getPublicKey.call(void 0, privateKey.slice(2)));
60
102
  const address = publicKeyToAddress(publicKey);
61
- const account = _chunkFQM5MF6Ujs.toAccount.call(void 0, {
103
+ const account = _chunkXLIQDCZWjs.toAccount.call(void 0, {
62
104
  address,
63
105
  async signMessage({ message }) {
64
106
  return signMessage({ message, privateKey });
65
107
  },
66
- async signTransaction(_transaction) {
67
- return "0x";
108
+ async signTransaction(transaction) {
109
+ return signTransaction({ privateKey, transaction });
68
110
  },
69
111
  async signTypedData(typedData) {
70
112
  return signTypedData({ ...typedData, privateKey });
@@ -72,12 +114,33 @@ function privateKeyToAccount(privateKey) {
72
114
  });
73
115
  return {
74
116
  ...account,
75
- getPrivateKey: () => privateKey,
76
117
  publicKey,
77
118
  source: "privateKey"
78
119
  };
79
120
  }
80
121
 
122
+ // src/accounts/wordlists.ts
123
+ var _czech = require('@scure/bip39/wordlists/czech');
124
+ var _english = require('@scure/bip39/wordlists/english');
125
+ var _french = require('@scure/bip39/wordlists/french');
126
+ var _italian = require('@scure/bip39/wordlists/italian');
127
+ var _japanese = require('@scure/bip39/wordlists/japanese');
128
+ var _korean = require('@scure/bip39/wordlists/korean');
129
+ var _simplifiedchinese = require('@scure/bip39/wordlists/simplified-chinese');
130
+ var _spanish = require('@scure/bip39/wordlists/spanish');
131
+ var _traditionalchinese = require('@scure/bip39/wordlists/traditional-chinese');
132
+
133
+
134
+
135
+
136
+
137
+
138
+
139
+
140
+
141
+
142
+
143
+
81
144
 
82
145
 
83
146
 
@@ -85,5 +148,5 @@ function privateKeyToAccount(privateKey) {
85
148
 
86
149
 
87
150
 
88
- exports.HDKey = _bip32.HDKey; exports.parseAccount = _chunkNJSAEA2Hjs.parseAccount; exports.privateKeyToAccount = privateKeyToAccount; exports.publicKeyToAddress = publicKeyToAddress; exports.signMessage = signMessage; exports.signTypedData = signTypedData; exports.toAccount = _chunkFQM5MF6Ujs.toAccount;
151
+ exports.HDKey = _bip32.HDKey; exports.czech = _czech.wordlist; exports.english = _english.wordlist; exports.french = _french.wordlist; exports.generateMnemonic = generateMnemonic; exports.generatePrivateKey = generatePrivateKey; exports.italian = _italian.wordlist; exports.japanese = _japanese.wordlist; exports.korean = _korean.wordlist; exports.parseAccount = _chunkCGTZNR2Rjs.parseAccount; exports.privateKeyToAccount = privateKeyToAccount; exports.publicKeyToAddress = publicKeyToAddress; exports.signMessage = signMessage; exports.signTypedData = signTypedData; exports.simplifiedChinese = _simplifiedchinese.wordlist; exports.spanish = _spanish.wordlist; exports.toAccount = _chunkXLIQDCZWjs.toAccount; exports.traditionalChinese = _traditionalchinese.wordlist;
89
152
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/accounts/index.ts","../../src/accounts/privateKeyToAccount.ts","../../src/accounts/utils/publicKeyToAddress.ts","../../src/accounts/utils/sign.ts","../../src/accounts/utils/signMessage.ts","../../src/accounts/utils/signTypedData.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,SAAS,aAAa;;;ACAtB,SAAS,oBAAoB;;;ACItB,SAAS,mBAAmB,WAAyB;AAC1D,QAAM,UAAU,UAAU,KAAK,UAAU,UAAU,CAAC,GAAG,EAAE,UAAU,EAAE;AACrE,SAAO,gBAAgB,KAAK,SAAS;AACvC;;;ACPA,SAAS,QAAQ,OAAO,iBAAiB;AAUzC,eAAsB,KAAK;AAAA,EACzB;AAAA,EACA;AACF,GAA4C;AAC1C,QAAM,CAAC,WAAW,KAAK,IAAI,MAAM,MAAM,KAAK,MAAM,CAAC,GAAG,WAAW,MAAM,CAAC,GAAG;AAAA,IACzE,WAAW;AAAA,IACX,WAAW;AAAA,EACb,CAAC;AACD,SAAO,KAAK,UAAU,QAAQ,SAAS,EAAE,aAAa,IACpD,QAAQ,OAAO;AAEnB;;;ACXA,eAAsB,YAAY;AAAA,EAChC;AAAA,EACA;AACF,GAA0D;AACxD,SAAO,KAAK,EAAE,MAAM,YAAY,OAAO,GAAG,WAAW,CAAC;AACxD;;;ACAA,eAAsB,cAGpB;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAGqC;AACnC,SAAO,KAAK;AAAA,IACV,MAAM,cAAc,SAAoC;AAAA,IACxD;AAAA,EACF,CAAC;AACH;;;AJrBO,SAAS,oBAAoB,YAAoC;AACtE,QAAM,YAAY,MAAM,aAAa,WAAW,MAAM,CAAC,CAAC,CAAC;AACzD,QAAM,UAAU,mBAAmB,SAAS;AAE5C,QAAM,UAAU,UAAU;AAAA,IACxB;AAAA,IACA,MAAM,YAAY,EAAE,QAAQ,GAAG;AAC7B,aAAO,YAAY,EAAE,SAAS,WAAW,CAAC;AAAA,IAC5C;AAAA,IACA,MAAM,gBAAgB,cAAc;AAElC,aAAO;AAAA,IACT;AAAA,IACA,MAAM,cAAc,WAAW;AAC7B,aAAO,cAAc,EAAE,GAAG,WAAW,WAAW,CAAC;AAAA,IACnD;AAAA,EACF,CAAC;AAED,SAAO;AAAA,IACL,GAAG;AAAA,IACH,eAAe,MAAM;AAAA,IACrB;AAAA,IACA,QAAQ;AAAA,EACV;AACF","sourcesContent":["import { HDKey } from '@scure/bip32'\n\nexport { HDKey }\n\nexport { privateKeyToAccount } from './privateKeyToAccount'\n\nexport { toAccount } from './toAccount'\n\nexport type {\n Account,\n AccountSource,\n CustomSource,\n HDOptions,\n JsonRpcAccount,\n LocalAccount,\n HDAccount,\n PrivateKeyAccount,\n} from './types'\n\nexport type {\n SignMessageParameters,\n SignMessageReturnType,\n SignTypedDataParameters,\n SignTypedDataReturnType,\n} from './utils'\nexport {\n parseAccount,\n publicKeyToAddress,\n signMessage,\n signTypedData,\n} from './utils'\n","import { getPublicKey } from '@noble/secp256k1'\n\nimport type { Hex } from '../types'\nimport { toHex } from '../utils'\nimport { publicKeyToAddress, signMessage, signTypedData } from './utils'\nimport { toAccount } from './toAccount'\nimport type { PrivateKeyAccount } from './types'\n\nexport function privateKeyToAccount(privateKey: Hex): PrivateKeyAccount {\n const publicKey = toHex(getPublicKey(privateKey.slice(2)))\n const address = publicKeyToAddress(publicKey)\n\n const account = toAccount({\n address,\n async signMessage({ message }) {\n return signMessage({ message, privateKey })\n },\n async signTransaction(_transaction) {\n // TODO\n return '0x'\n },\n async signTypedData(typedData) {\n return signTypedData({ ...typedData, privateKey })\n },\n })\n\n return {\n ...account,\n getPrivateKey: () => privateKey,\n publicKey,\n source: 'privateKey',\n }\n}\n","import type { Address, Hex } from '../../types'\nimport { keccak256 } from '../../utils'\nimport { checksumAddress } from '../../utils/address'\n\nexport function publicKeyToAddress(publicKey: Hex): Address {\n const address = keccak256(`0x${publicKey.substring(4)}`).substring(26)\n return checksumAddress(`0x${address}`) as Address\n}\n","import { sign as sign_, Signature } from '@noble/secp256k1'\n\nimport type { Hex } from '../../types'\n\nexport type SignParameters = {\n hash: Hex\n privateKey: Hex\n}\nexport type SignReturnType = Hex\n\nexport async function sign({\n hash,\n privateKey,\n}: SignParameters): Promise<SignReturnType> {\n const [signature, recId] = await sign_(hash.slice(2), privateKey.slice(2), {\n canonical: true,\n recovered: true,\n })\n return `0x${Signature.fromHex(signature).toCompactHex()}${\n recId ? '1c' : '1b'\n }`\n}\n","import type { Hex } from '../../types'\nimport { hashMessage } from '../../utils'\nimport { sign } from './sign'\n\nexport type SignMessageParameters = {\n message: string\n privateKey: Hex\n}\nexport type SignMessageReturnType = Hex\n\nexport async function signMessage({\n message,\n privateKey,\n}: SignMessageParameters): Promise<SignMessageReturnType> {\n return sign({ hash: hashMessage(message), privateKey })\n}\n","import type { TypedData } from 'abitype'\n\nimport type { Hex, TypedDataDefinition } from '../../types'\nimport { HashTypedDataParameters, hashTypedData } from '../../utils'\nimport { sign } from './sign'\n\nexport type SignTypedDataParameters<\n TTypedData extends TypedData | { [key: string]: unknown } = TypedData,\n TPrimaryType extends string = string,\n> = TypedDataDefinition<TTypedData, TPrimaryType> & {\n privateKey: Hex\n}\n\nexport type SignTypedDataReturnType = Hex\n\nexport async function signTypedData<\n TTypedData extends TypedData | { [key: string]: unknown },\n TPrimaryType extends string = string,\n>({\n privateKey,\n ...typedData\n}: SignTypedDataParameters<\n TTypedData,\n TPrimaryType\n>): Promise<SignTypedDataReturnType> {\n return sign({\n hash: hashTypedData(typedData as HashTypedDataParameters),\n privateKey,\n })\n}\n"]}
1
+ {"version":3,"sources":["../../src/accounts/index.ts","../../src/accounts/generateMnemonic.ts","../../src/accounts/generatePrivateKey.ts","../../src/accounts/privateKeyToAccount.ts","../../src/accounts/utils/publicKeyToAddress.ts","../../src/accounts/utils/sign.ts","../../src/accounts/utils/signatureToHex.ts","../../src/accounts/utils/signMessage.ts","../../src/accounts/utils/signTransaction.ts","../../src/accounts/utils/signTypedData.ts","../../src/accounts/wordlists.ts"],"names":["wordlist","Signature_"],"mappings":"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","sourcesContent":["import { HDKey } from '@scure/bip32'\n\nexport { HDKey }\n\nexport { generateMnemonic } from './generateMnemonic'\n\nexport { generatePrivateKey } from './generatePrivateKey'\n\nexport { privateKeyToAccount } from './privateKeyToAccount'\n\nexport { toAccount } from './toAccount'\n\nexport type {\n Account,\n AccountSource,\n CustomSource,\n HDOptions,\n JsonRpcAccount,\n LocalAccount,\n HDAccount,\n PrivateKeyAccount,\n} from './types'\n\nexport type {\n SignMessageParameters,\n SignMessageReturnType,\n SignTypedDataParameters,\n SignTypedDataReturnType,\n} from './utils'\nexport {\n parseAccount,\n publicKeyToAddress,\n signMessage,\n signTypedData,\n} from './utils'\n\nexport {\n czech,\n english,\n french,\n italian,\n japanese,\n korean,\n simplifiedChinese,\n spanish,\n traditionalChinese,\n} from './wordlists'\n","import { generateMnemonic as generateMnemonic_ } from '@scure/bip39'\n\n/**\n * @description Generates a random mnemonic phrase with a given wordlist.\n *\n * @param wordlist The wordlist to use for generating the mnemonic phrase.\n *\n * @returns A randomly generated mnemonic phrase.\n */\nexport function generateMnemonic(wordlist: string[]): string {\n return generateMnemonic_(wordlist)\n}\n","import { utils } from '@noble/secp256k1'\n\nimport type { Hex } from '../types'\nimport { toHex } from '../utils'\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(utils.randomPrivateKey())\n}\n","import { getPublicKey } from '@noble/secp256k1'\n\nimport type { Hex } from '../types'\nimport { toHex } from '../utils'\nimport {\n publicKeyToAddress,\n signMessage,\n signTransaction,\n signTypedData,\n} from './utils'\nimport { toAccount } from './toAccount'\nimport type { PrivateKeyAccount } from './types'\n\n/**\n * @description Creates an Account from a private key.\n *\n * @returns A Private Key Account.\n */\nexport function privateKeyToAccount(privateKey: Hex): PrivateKeyAccount {\n const publicKey = toHex(getPublicKey(privateKey.slice(2)))\n const address = publicKeyToAddress(publicKey)\n\n const account = toAccount({\n address,\n async signMessage({ message }) {\n return signMessage({ message, privateKey })\n },\n async signTransaction(transaction) {\n return signTransaction({ privateKey, transaction })\n },\n async signTypedData(typedData) {\n return signTypedData({ ...typedData, privateKey })\n },\n })\n\n return {\n ...account,\n publicKey,\n source: 'privateKey',\n }\n}\n","import type { Address, Hex } from '../../types'\nimport { keccak256 } from '../../utils'\nimport { checksumAddress } from '../../utils/address'\n\n/**\n * @description Converts an ECDSA public key to an address.\n *\n * @param publicKey The public key to convert.\n *\n * @returns The address.\n */\nexport function publicKeyToAddress(publicKey: Hex): Address {\n const address = keccak256(`0x${publicKey.substring(4)}`).substring(26)\n return checksumAddress(`0x${address}`) as Address\n}\n","import { sign as sign_, Signature as Signature_ } from '@noble/secp256k1'\n\nimport type { Hex, Signature } from '../../types'\nimport { toHex } from '../../utils'\n\nexport type SignParameters = {\n hash: Hex\n privateKey: Hex\n}\nexport type SignReturnType = Signature\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({\n hash,\n privateKey,\n}: SignParameters): Promise<SignReturnType> {\n const [sigBytes, recId] = await sign_(hash.slice(2), privateKey.slice(2), {\n canonical: true,\n recovered: true,\n })\n const sig = Signature_.fromHex(sigBytes)\n return {\n r: toHex(sig.r),\n s: toHex(sig.s),\n v: recId ? 28n : 27n,\n }\n}\n","import { Signature as Signature_ } from '@noble/secp256k1'\n\nimport type { Hex, Signature } from '../../types'\nimport { hexToBigInt, toHex } from '../../utils'\n\nexport function signatureToHex({ r, s, v }: Signature): Hex {\n return `0x${new Signature_(\n hexToBigInt(r),\n hexToBigInt(s),\n ).toCompactHex()}${toHex(v).slice(2)}`\n}\n","import type { Hex } from '../../types'\nimport { hashMessage } from '../../utils'\nimport { sign } from './sign'\nimport { signatureToHex } from './signatureToHex'\n\nexport type SignMessageParameters = {\n /** The message to sign. */\n message: string\n /** The private key to sign with. */\n privateKey: Hex\n}\nexport type SignMessageReturnType = Hex\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 const signature = await sign({ hash: hashMessage(message), privateKey })\n return signatureToHex(signature)\n}\n","import type {\n Hex,\n TransactionSerializable,\n TransactionSerialized,\n TransactionType,\n} from '../../types'\nimport {\n GetTransactionType,\n keccak256,\n serializeTransaction,\n} from '../../utils'\nimport { sign } from './sign'\n\nexport type SignTransactionArgs<\n TTransactionSerializable extends TransactionSerializable = TransactionSerializable,\n> = {\n privateKey: Hex\n transaction: TTransactionSerializable\n}\nexport type SignTransactionReturnType<\n TTransactionSerializable extends TransactionSerializable = TransactionSerializable,\n TTransactionType extends TransactionType = GetTransactionType<TTransactionSerializable>,\n> = TransactionSerialized<TTransactionType>\n\nexport async function signTransaction<\n TTransactionSerializable extends TransactionSerializable,\n>({\n privateKey,\n transaction,\n}: SignTransactionArgs<TTransactionSerializable>): Promise<\n SignTransactionReturnType<TTransactionSerializable>\n> {\n const signature = await sign({\n hash: keccak256(serializeTransaction(transaction)),\n privateKey,\n })\n return serializeTransaction(transaction, signature)\n}\n","import type { TypedData } from 'abitype'\n\nimport type { Hex, TypedDataDefinition } from '../../types'\nimport { HashTypedDataParameters, hashTypedData } from '../../utils'\nimport { sign } from './sign'\nimport { signatureToHex } from './signatureToHex'\n\nexport type SignTypedDataParameters<\n TTypedData extends TypedData | { [key: string]: unknown } = TypedData,\n TPrimaryType extends string = string,\n> = TypedDataDefinition<TTypedData, TPrimaryType> & {\n /** The private key to sign with. */\n privateKey: Hex\n}\n\nexport type SignTypedDataReturnType = Hex\n\n/**\n * @description Signs typed data and 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 signTypedData<\n TTypedData extends TypedData | { [key: string]: unknown },\n TPrimaryType extends string = string,\n>({\n privateKey,\n ...typedData\n}: SignTypedDataParameters<\n TTypedData,\n TPrimaryType\n>): Promise<SignTypedDataReturnType> {\n const signature = await sign({\n hash: hashTypedData(typedData as HashTypedDataParameters),\n privateKey,\n })\n return signatureToHex(signature)\n}\n","export { wordlist as czech } from '@scure/bip39/wordlists/czech'\nexport { wordlist as english } from '@scure/bip39/wordlists/english'\nexport { wordlist as french } from '@scure/bip39/wordlists/french'\nexport { wordlist as italian } from '@scure/bip39/wordlists/italian'\nexport { wordlist as japanese } from '@scure/bip39/wordlists/japanese'\nexport { wordlist as korean } from '@scure/bip39/wordlists/korean'\nexport { wordlist as simplifiedChinese } from '@scure/bip39/wordlists/simplified-chinese'\nexport { wordlist as spanish } from '@scure/bip39/wordlists/spanish'\nexport { wordlist as traditionalChinese } from '@scure/bip39/wordlists/traditional-chinese'\n"]}
@@ -1,18 +1,32 @@
1
1
  import {
2
2
  toAccount
3
- } from "../chunk-FNVFGFWN.mjs";
3
+ } from "../chunk-PVK5TA2L.mjs";
4
4
  import {
5
5
  checksumAddress,
6
6
  hashMessage,
7
7
  hashTypedData,
8
+ hexToBigInt,
8
9
  keccak256,
9
10
  parseAccount,
11
+ serializeTransaction,
10
12
  toHex
11
- } from "../chunk-IVRML3IK.mjs";
13
+ } from "../chunk-HWVZ6VEQ.mjs";
12
14
 
13
15
  // src/accounts/index.ts
14
16
  import { HDKey } from "@scure/bip32";
15
17
 
18
+ // src/accounts/generateMnemonic.ts
19
+ import { generateMnemonic as generateMnemonic_ } from "@scure/bip39";
20
+ function generateMnemonic(wordlist10) {
21
+ return generateMnemonic_(wordlist10);
22
+ }
23
+
24
+ // src/accounts/generatePrivateKey.ts
25
+ import { utils } from "@noble/secp256k1";
26
+ function generatePrivateKey() {
27
+ return toHex(utils.randomPrivateKey());
28
+ }
29
+
16
30
  // src/accounts/privateKeyToAccount.ts
17
31
  import { getPublicKey } from "@noble/secp256k1";
18
32
 
@@ -23,16 +37,30 @@ function publicKeyToAddress(publicKey) {
23
37
  }
24
38
 
25
39
  // src/accounts/utils/sign.ts
26
- import { sign as sign_, Signature } from "@noble/secp256k1";
40
+ import { sign as sign_, Signature as Signature_ } from "@noble/secp256k1";
27
41
  async function sign({
28
42
  hash,
29
43
  privateKey
30
44
  }) {
31
- const [signature, recId] = await sign_(hash.slice(2), privateKey.slice(2), {
45
+ const [sigBytes, recId] = await sign_(hash.slice(2), privateKey.slice(2), {
32
46
  canonical: true,
33
47
  recovered: true
34
48
  });
35
- return `0x${Signature.fromHex(signature).toCompactHex()}${recId ? "1c" : "1b"}`;
49
+ const sig = Signature_.fromHex(sigBytes);
50
+ return {
51
+ r: toHex(sig.r),
52
+ s: toHex(sig.s),
53
+ v: recId ? 28n : 27n
54
+ };
55
+ }
56
+
57
+ // src/accounts/utils/signatureToHex.ts
58
+ import { Signature as Signature_2 } from "@noble/secp256k1";
59
+ function signatureToHex({ r, s, v }) {
60
+ return `0x${new Signature_2(
61
+ hexToBigInt(r),
62
+ hexToBigInt(s)
63
+ ).toCompactHex()}${toHex(v).slice(2)}`;
36
64
  }
37
65
 
38
66
  // src/accounts/utils/signMessage.ts
@@ -40,7 +68,20 @@ async function signMessage({
40
68
  message,
41
69
  privateKey
42
70
  }) {
43
- return sign({ hash: hashMessage(message), privateKey });
71
+ const signature = await sign({ hash: hashMessage(message), privateKey });
72
+ return signatureToHex(signature);
73
+ }
74
+
75
+ // src/accounts/utils/signTransaction.ts
76
+ async function signTransaction({
77
+ privateKey,
78
+ transaction
79
+ }) {
80
+ const signature = await sign({
81
+ hash: keccak256(serializeTransaction(transaction)),
82
+ privateKey
83
+ });
84
+ return serializeTransaction(transaction, signature);
44
85
  }
45
86
 
46
87
  // src/accounts/utils/signTypedData.ts
@@ -48,10 +89,11 @@ async function signTypedData({
48
89
  privateKey,
49
90
  ...typedData
50
91
  }) {
51
- return sign({
92
+ const signature = await sign({
52
93
  hash: hashTypedData(typedData),
53
94
  privateKey
54
95
  });
96
+ return signatureToHex(signature);
55
97
  }
56
98
 
57
99
  // src/accounts/privateKeyToAccount.ts
@@ -63,8 +105,8 @@ function privateKeyToAccount(privateKey) {
63
105
  async signMessage({ message }) {
64
106
  return signMessage({ message, privateKey });
65
107
  },
66
- async signTransaction(_transaction) {
67
- return "0x";
108
+ async signTransaction(transaction) {
109
+ return signTransaction({ privateKey, transaction });
68
110
  },
69
111
  async signTypedData(typedData) {
70
112
  return signTypedData({ ...typedData, privateKey });
@@ -72,18 +114,39 @@ function privateKeyToAccount(privateKey) {
72
114
  });
73
115
  return {
74
116
  ...account,
75
- getPrivateKey: () => privateKey,
76
117
  publicKey,
77
118
  source: "privateKey"
78
119
  };
79
120
  }
121
+
122
+ // src/accounts/wordlists.ts
123
+ import { wordlist } from "@scure/bip39/wordlists/czech";
124
+ import { wordlist as wordlist2 } from "@scure/bip39/wordlists/english";
125
+ import { wordlist as wordlist3 } from "@scure/bip39/wordlists/french";
126
+ import { wordlist as wordlist4 } from "@scure/bip39/wordlists/italian";
127
+ import { wordlist as wordlist5 } from "@scure/bip39/wordlists/japanese";
128
+ import { wordlist as wordlist6 } from "@scure/bip39/wordlists/korean";
129
+ import { wordlist as wordlist7 } from "@scure/bip39/wordlists/simplified-chinese";
130
+ import { wordlist as wordlist8 } from "@scure/bip39/wordlists/spanish";
131
+ import { wordlist as wordlist9 } from "@scure/bip39/wordlists/traditional-chinese";
80
132
  export {
81
133
  HDKey,
134
+ wordlist as czech,
135
+ wordlist2 as english,
136
+ wordlist3 as french,
137
+ generateMnemonic,
138
+ generatePrivateKey,
139
+ wordlist4 as italian,
140
+ wordlist5 as japanese,
141
+ wordlist6 as korean,
82
142
  parseAccount,
83
143
  privateKeyToAccount,
84
144
  publicKeyToAddress,
85
145
  signMessage,
86
146
  signTypedData,
87
- toAccount
147
+ wordlist7 as simplifiedChinese,
148
+ wordlist8 as spanish,
149
+ toAccount,
150
+ wordlist9 as traditionalChinese
88
151
  };
89
152
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/accounts/index.ts","../../src/accounts/privateKeyToAccount.ts","../../src/accounts/utils/publicKeyToAddress.ts","../../src/accounts/utils/sign.ts","../../src/accounts/utils/signMessage.ts","../../src/accounts/utils/signTypedData.ts"],"sourcesContent":["import { HDKey } from '@scure/bip32'\n\nexport { HDKey }\n\nexport { privateKeyToAccount } from './privateKeyToAccount'\n\nexport { toAccount } from './toAccount'\n\nexport type {\n Account,\n AccountSource,\n CustomSource,\n HDOptions,\n JsonRpcAccount,\n LocalAccount,\n HDAccount,\n PrivateKeyAccount,\n} from './types'\n\nexport type {\n SignMessageParameters,\n SignMessageReturnType,\n SignTypedDataParameters,\n SignTypedDataReturnType,\n} from './utils'\nexport {\n parseAccount,\n publicKeyToAddress,\n signMessage,\n signTypedData,\n} from './utils'\n","import { getPublicKey } from '@noble/secp256k1'\n\nimport type { Hex } from '../types'\nimport { toHex } from '../utils'\nimport { publicKeyToAddress, signMessage, signTypedData } from './utils'\nimport { toAccount } from './toAccount'\nimport type { PrivateKeyAccount } from './types'\n\nexport function privateKeyToAccount(privateKey: Hex): PrivateKeyAccount {\n const publicKey = toHex(getPublicKey(privateKey.slice(2)))\n const address = publicKeyToAddress(publicKey)\n\n const account = toAccount({\n address,\n async signMessage({ message }) {\n return signMessage({ message, privateKey })\n },\n async signTransaction(_transaction) {\n // TODO\n return '0x'\n },\n async signTypedData(typedData) {\n return signTypedData({ ...typedData, privateKey })\n },\n })\n\n return {\n ...account,\n getPrivateKey: () => privateKey,\n publicKey,\n source: 'privateKey',\n }\n}\n","import type { Address, Hex } from '../../types'\nimport { keccak256 } from '../../utils'\nimport { checksumAddress } from '../../utils/address'\n\nexport function publicKeyToAddress(publicKey: Hex): Address {\n const address = keccak256(`0x${publicKey.substring(4)}`).substring(26)\n return checksumAddress(`0x${address}`) as Address\n}\n","import { sign as sign_, Signature } from '@noble/secp256k1'\n\nimport type { Hex } from '../../types'\n\nexport type SignParameters = {\n hash: Hex\n privateKey: Hex\n}\nexport type SignReturnType = Hex\n\nexport async function sign({\n hash,\n privateKey,\n}: SignParameters): Promise<SignReturnType> {\n const [signature, recId] = await sign_(hash.slice(2), privateKey.slice(2), {\n canonical: true,\n recovered: true,\n })\n return `0x${Signature.fromHex(signature).toCompactHex()}${\n recId ? '1c' : '1b'\n }`\n}\n","import type { Hex } from '../../types'\nimport { hashMessage } from '../../utils'\nimport { sign } from './sign'\n\nexport type SignMessageParameters = {\n message: string\n privateKey: Hex\n}\nexport type SignMessageReturnType = Hex\n\nexport async function signMessage({\n message,\n privateKey,\n}: SignMessageParameters): Promise<SignMessageReturnType> {\n return sign({ hash: hashMessage(message), privateKey })\n}\n","import type { TypedData } from 'abitype'\n\nimport type { Hex, TypedDataDefinition } from '../../types'\nimport { HashTypedDataParameters, hashTypedData } from '../../utils'\nimport { sign } from './sign'\n\nexport type SignTypedDataParameters<\n TTypedData extends TypedData | { [key: string]: unknown } = TypedData,\n TPrimaryType extends string = string,\n> = TypedDataDefinition<TTypedData, TPrimaryType> & {\n privateKey: Hex\n}\n\nexport type SignTypedDataReturnType = Hex\n\nexport async function signTypedData<\n TTypedData extends TypedData | { [key: string]: unknown },\n TPrimaryType extends string = string,\n>({\n privateKey,\n ...typedData\n}: SignTypedDataParameters<\n TTypedData,\n TPrimaryType\n>): Promise<SignTypedDataReturnType> {\n return sign({\n hash: hashTypedData(typedData as HashTypedDataParameters),\n privateKey,\n })\n}\n"],"mappings":";;;;;;;;;;;;;AAAA,SAAS,aAAa;;;ACAtB,SAAS,oBAAoB;;;ACItB,SAAS,mBAAmB,WAAyB;AAC1D,QAAM,UAAU,UAAU,KAAK,UAAU,UAAU,CAAC,GAAG,EAAE,UAAU,EAAE;AACrE,SAAO,gBAAgB,KAAK,SAAS;AACvC;;;ACPA,SAAS,QAAQ,OAAO,iBAAiB;AAUzC,eAAsB,KAAK;AAAA,EACzB;AAAA,EACA;AACF,GAA4C;AAC1C,QAAM,CAAC,WAAW,KAAK,IAAI,MAAM,MAAM,KAAK,MAAM,CAAC,GAAG,WAAW,MAAM,CAAC,GAAG;AAAA,IACzE,WAAW;AAAA,IACX,WAAW;AAAA,EACb,CAAC;AACD,SAAO,KAAK,UAAU,QAAQ,SAAS,EAAE,aAAa,IACpD,QAAQ,OAAO;AAEnB;;;ACXA,eAAsB,YAAY;AAAA,EAChC;AAAA,EACA;AACF,GAA0D;AACxD,SAAO,KAAK,EAAE,MAAM,YAAY,OAAO,GAAG,WAAW,CAAC;AACxD;;;ACAA,eAAsB,cAGpB;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAGqC;AACnC,SAAO,KAAK;AAAA,IACV,MAAM,cAAc,SAAoC;AAAA,IACxD;AAAA,EACF,CAAC;AACH;;;AJrBO,SAAS,oBAAoB,YAAoC;AACtE,QAAM,YAAY,MAAM,aAAa,WAAW,MAAM,CAAC,CAAC,CAAC;AACzD,QAAM,UAAU,mBAAmB,SAAS;AAE5C,QAAM,UAAU,UAAU;AAAA,IACxB;AAAA,IACA,MAAM,YAAY,EAAE,QAAQ,GAAG;AAC7B,aAAO,YAAY,EAAE,SAAS,WAAW,CAAC;AAAA,IAC5C;AAAA,IACA,MAAM,gBAAgB,cAAc;AAElC,aAAO;AAAA,IACT;AAAA,IACA,MAAM,cAAc,WAAW;AAC7B,aAAO,cAAc,EAAE,GAAG,WAAW,WAAW,CAAC;AAAA,IACnD;AAAA,EACF,CAAC;AAED,SAAO;AAAA,IACL,GAAG;AAAA,IACH,eAAe,MAAM;AAAA,IACrB;AAAA,IACA,QAAQ;AAAA,EACV;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/accounts/index.ts","../../src/accounts/generateMnemonic.ts","../../src/accounts/generatePrivateKey.ts","../../src/accounts/privateKeyToAccount.ts","../../src/accounts/utils/publicKeyToAddress.ts","../../src/accounts/utils/sign.ts","../../src/accounts/utils/signatureToHex.ts","../../src/accounts/utils/signMessage.ts","../../src/accounts/utils/signTransaction.ts","../../src/accounts/utils/signTypedData.ts","../../src/accounts/wordlists.ts"],"sourcesContent":["import { HDKey } from '@scure/bip32'\n\nexport { HDKey }\n\nexport { generateMnemonic } from './generateMnemonic'\n\nexport { generatePrivateKey } from './generatePrivateKey'\n\nexport { privateKeyToAccount } from './privateKeyToAccount'\n\nexport { toAccount } from './toAccount'\n\nexport type {\n Account,\n AccountSource,\n CustomSource,\n HDOptions,\n JsonRpcAccount,\n LocalAccount,\n HDAccount,\n PrivateKeyAccount,\n} from './types'\n\nexport type {\n SignMessageParameters,\n SignMessageReturnType,\n SignTypedDataParameters,\n SignTypedDataReturnType,\n} from './utils'\nexport {\n parseAccount,\n publicKeyToAddress,\n signMessage,\n signTypedData,\n} from './utils'\n\nexport {\n czech,\n english,\n french,\n italian,\n japanese,\n korean,\n simplifiedChinese,\n spanish,\n traditionalChinese,\n} from './wordlists'\n","import { generateMnemonic as generateMnemonic_ } from '@scure/bip39'\n\n/**\n * @description Generates a random mnemonic phrase with a given wordlist.\n *\n * @param wordlist The wordlist to use for generating the mnemonic phrase.\n *\n * @returns A randomly generated mnemonic phrase.\n */\nexport function generateMnemonic(wordlist: string[]): string {\n return generateMnemonic_(wordlist)\n}\n","import { utils } from '@noble/secp256k1'\n\nimport type { Hex } from '../types'\nimport { toHex } from '../utils'\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(utils.randomPrivateKey())\n}\n","import { getPublicKey } from '@noble/secp256k1'\n\nimport type { Hex } from '../types'\nimport { toHex } from '../utils'\nimport {\n publicKeyToAddress,\n signMessage,\n signTransaction,\n signTypedData,\n} from './utils'\nimport { toAccount } from './toAccount'\nimport type { PrivateKeyAccount } from './types'\n\n/**\n * @description Creates an Account from a private key.\n *\n * @returns A Private Key Account.\n */\nexport function privateKeyToAccount(privateKey: Hex): PrivateKeyAccount {\n const publicKey = toHex(getPublicKey(privateKey.slice(2)))\n const address = publicKeyToAddress(publicKey)\n\n const account = toAccount({\n address,\n async signMessage({ message }) {\n return signMessage({ message, privateKey })\n },\n async signTransaction(transaction) {\n return signTransaction({ privateKey, transaction })\n },\n async signTypedData(typedData) {\n return signTypedData({ ...typedData, privateKey })\n },\n })\n\n return {\n ...account,\n publicKey,\n source: 'privateKey',\n }\n}\n","import type { Address, Hex } from '../../types'\nimport { keccak256 } from '../../utils'\nimport { checksumAddress } from '../../utils/address'\n\n/**\n * @description Converts an ECDSA public key to an address.\n *\n * @param publicKey The public key to convert.\n *\n * @returns The address.\n */\nexport function publicKeyToAddress(publicKey: Hex): Address {\n const address = keccak256(`0x${publicKey.substring(4)}`).substring(26)\n return checksumAddress(`0x${address}`) as Address\n}\n","import { sign as sign_, Signature as Signature_ } from '@noble/secp256k1'\n\nimport type { Hex, Signature } from '../../types'\nimport { toHex } from '../../utils'\n\nexport type SignParameters = {\n hash: Hex\n privateKey: Hex\n}\nexport type SignReturnType = Signature\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({\n hash,\n privateKey,\n}: SignParameters): Promise<SignReturnType> {\n const [sigBytes, recId] = await sign_(hash.slice(2), privateKey.slice(2), {\n canonical: true,\n recovered: true,\n })\n const sig = Signature_.fromHex(sigBytes)\n return {\n r: toHex(sig.r),\n s: toHex(sig.s),\n v: recId ? 28n : 27n,\n }\n}\n","import { Signature as Signature_ } from '@noble/secp256k1'\n\nimport type { Hex, Signature } from '../../types'\nimport { hexToBigInt, toHex } from '../../utils'\n\nexport function signatureToHex({ r, s, v }: Signature): Hex {\n return `0x${new Signature_(\n hexToBigInt(r),\n hexToBigInt(s),\n ).toCompactHex()}${toHex(v).slice(2)}`\n}\n","import type { Hex } from '../../types'\nimport { hashMessage } from '../../utils'\nimport { sign } from './sign'\nimport { signatureToHex } from './signatureToHex'\n\nexport type SignMessageParameters = {\n /** The message to sign. */\n message: string\n /** The private key to sign with. */\n privateKey: Hex\n}\nexport type SignMessageReturnType = Hex\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 const signature = await sign({ hash: hashMessage(message), privateKey })\n return signatureToHex(signature)\n}\n","import type {\n Hex,\n TransactionSerializable,\n TransactionSerialized,\n TransactionType,\n} from '../../types'\nimport {\n GetTransactionType,\n keccak256,\n serializeTransaction,\n} from '../../utils'\nimport { sign } from './sign'\n\nexport type SignTransactionArgs<\n TTransactionSerializable extends TransactionSerializable = TransactionSerializable,\n> = {\n privateKey: Hex\n transaction: TTransactionSerializable\n}\nexport type SignTransactionReturnType<\n TTransactionSerializable extends TransactionSerializable = TransactionSerializable,\n TTransactionType extends TransactionType = GetTransactionType<TTransactionSerializable>,\n> = TransactionSerialized<TTransactionType>\n\nexport async function signTransaction<\n TTransactionSerializable extends TransactionSerializable,\n>({\n privateKey,\n transaction,\n}: SignTransactionArgs<TTransactionSerializable>): Promise<\n SignTransactionReturnType<TTransactionSerializable>\n> {\n const signature = await sign({\n hash: keccak256(serializeTransaction(transaction)),\n privateKey,\n })\n return serializeTransaction(transaction, signature)\n}\n","import type { TypedData } from 'abitype'\n\nimport type { Hex, TypedDataDefinition } from '../../types'\nimport { HashTypedDataParameters, hashTypedData } from '../../utils'\nimport { sign } from './sign'\nimport { signatureToHex } from './signatureToHex'\n\nexport type SignTypedDataParameters<\n TTypedData extends TypedData | { [key: string]: unknown } = TypedData,\n TPrimaryType extends string = string,\n> = TypedDataDefinition<TTypedData, TPrimaryType> & {\n /** The private key to sign with. */\n privateKey: Hex\n}\n\nexport type SignTypedDataReturnType = Hex\n\n/**\n * @description Signs typed data and 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 signTypedData<\n TTypedData extends TypedData | { [key: string]: unknown },\n TPrimaryType extends string = string,\n>({\n privateKey,\n ...typedData\n}: SignTypedDataParameters<\n TTypedData,\n TPrimaryType\n>): Promise<SignTypedDataReturnType> {\n const signature = await sign({\n hash: hashTypedData(typedData as HashTypedDataParameters),\n privateKey,\n })\n return signatureToHex(signature)\n}\n","export { wordlist as czech } from '@scure/bip39/wordlists/czech'\nexport { wordlist as english } from '@scure/bip39/wordlists/english'\nexport { wordlist as french } from '@scure/bip39/wordlists/french'\nexport { wordlist as italian } from '@scure/bip39/wordlists/italian'\nexport { wordlist as japanese } from '@scure/bip39/wordlists/japanese'\nexport { wordlist as korean } from '@scure/bip39/wordlists/korean'\nexport { wordlist as simplifiedChinese } from '@scure/bip39/wordlists/simplified-chinese'\nexport { wordlist as spanish } from '@scure/bip39/wordlists/spanish'\nexport { wordlist as traditionalChinese } from '@scure/bip39/wordlists/traditional-chinese'\n"],"mappings":"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","names":["wordlist","Signature_","Signature_","wordlist"]}
@@ -1,4 +1,4 @@
1
- import { a1 as Formatters, C as Chain } from './chain-75b0942e.js';
1
+ import { ab as Formatters, C as Chain } from './chain-4af995bf.js';
2
2
 
3
3
  declare function defineChain<TFormatters extends Formatters = Formatters, TChain extends Chain<TFormatters> = Chain<TFormatters>>(chain: TChain): TChain;
4
4
  declare function getChainContractAddress({ blockNumber, chain, contract: name, }: {