viem 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/abi.js CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
 
9
9
 
10
- var _chunkYDNKDSSTjs = require('./chunk-YDNKDSST.js');
10
+ var _chunkIGFTD4HWjs = require('./chunk-IGFTD4HW.js');
11
11
 
12
12
 
13
13
 
@@ -17,5 +17,5 @@ var _chunkYDNKDSSTjs = require('./chunk-YDNKDSST.js');
17
17
 
18
18
 
19
19
 
20
- exports.decodeAbiParameters = _chunkYDNKDSSTjs.decodeAbiParameters; exports.encodeAbiParameters = _chunkYDNKDSSTjs.encodeAbiParameters; exports.encodePacked = _chunkYDNKDSSTjs.encodePacked; exports.getAbiItem = _chunkYDNKDSSTjs.getAbiItem; exports.parseAbi = _chunkYDNKDSSTjs.parseAbi; exports.parseAbiItem = _chunkYDNKDSSTjs.parseAbiItem; exports.parseAbiParameter = _chunkYDNKDSSTjs.parseAbiParameter; exports.parseAbiParameters = _chunkYDNKDSSTjs.parseAbiParameters;
20
+ exports.decodeAbiParameters = _chunkIGFTD4HWjs.decodeAbiParameters; exports.encodeAbiParameters = _chunkIGFTD4HWjs.encodeAbiParameters; exports.encodePacked = _chunkIGFTD4HWjs.encodePacked; exports.getAbiItem = _chunkIGFTD4HWjs.getAbiItem; exports.parseAbi = _chunkIGFTD4HWjs.parseAbi; exports.parseAbiItem = _chunkIGFTD4HWjs.parseAbiItem; exports.parseAbiParameter = _chunkIGFTD4HWjs.parseAbiParameter; exports.parseAbiParameters = _chunkIGFTD4HWjs.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-FSIBCQFR.mjs";
10
+ } from "./chunk-GJGV3W5S.mjs";
11
11
  export {
12
12
  decodeAbiParameters,
13
13
  encodeAbiParameters,
@@ -1,18 +1,10 @@
1
+ import { HDKey } from '@scure/bip32';
1
2
  export { HDKey } from '@scure/bip32';
2
3
  import { H as Hex } from '../chain-5507c6f0.js';
3
- import { P as PrivateKeyAccount, a as AccountSource, J as JsonRpcAccount, C as CustomSource, L as LocalAccount, T as TypedDataDefinition } from '../typedData-46b4d81f.js';
4
+ import { b as HDOptions, H as HDAccount, P as PrivateKeyAccount, a as AccountSource, J as JsonRpcAccount, C as CustomSource, L as LocalAccount, T as TypedDataDefinition } from '../typedData-46b4d81f.js';
4
5
  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-46b4d81f.js';
5
6
  import { Address, TypedData } from 'abitype';
6
7
  export { p as parseAccount, a as publicKeyToAddress } from '../publicKeyToAddress-623eb398.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';
16
8
  import '@wagmi/chains';
17
9
 
18
10
  /**
@@ -31,6 +23,20 @@ declare function generateMnemonic(wordlist: string[]): string;
31
23
  */
32
24
  declare function generatePrivateKey(): Hex;
33
25
 
26
+ /**
27
+ * @description Creates an Account from a HD Key.
28
+ *
29
+ * @returns A HD Account.
30
+ */
31
+ declare function hdKeyToAccount(hdKey_: HDKey, { accountIndex, addressIndex, changeIndex, path }?: HDOptions): HDAccount;
32
+
33
+ /**
34
+ * @description Creates an Account from a mnemonic phrase.
35
+ *
36
+ * @returns A HD Account.
37
+ */
38
+ declare function mnemonicToAccount(mnemonic: string, opts?: HDOptions): HDAccount;
39
+
34
40
  /**
35
41
  * @description Creates an Account from a private key.
36
42
  *
@@ -78,4 +84,22 @@ declare function signTypedData<TTypedData extends TypedData | {
78
84
  [key: string]: unknown;
79
85
  }, TPrimaryType extends string = string>({ privateKey, ...typedData }: SignTypedDataParameters<TTypedData, TPrimaryType>): Promise<SignTypedDataReturnType>;
80
86
 
81
- export { SignMessageParameters, SignMessageReturnType, SignTypedDataParameters, SignTypedDataReturnType, generateMnemonic, generatePrivateKey, privateKeyToAccount, signMessage, signTypedData, toAccount };
87
+ declare const czech: string[];
88
+
89
+ declare const english: string[];
90
+
91
+ declare const french: string[];
92
+
93
+ declare const italian: string[];
94
+
95
+ declare const japanese: string[];
96
+
97
+ declare const korean: string[];
98
+
99
+ declare const simplifiedChinese: string[];
100
+
101
+ declare const spanish: string[];
102
+
103
+ declare const traditionalChinese: string[];
104
+
105
+ export { SignMessageParameters, SignMessageReturnType, SignTypedDataParameters, SignTypedDataReturnType, czech, english, french, generateMnemonic, generatePrivateKey, hdKeyToAccount, italian, japanese, korean, mnemonicToAccount, privateKeyToAccount, signMessage, signTypedData, simplifiedChinese, spanish, toAccount, traditionalChinese };
@@ -1,6 +1,6 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2
2
 
3
- var _chunk63WKWOMOjs = require('../chunk-63WKWOMO.js');
3
+ var _chunkEP6BQLGRjs = require('../chunk-EP6BQLGR.js');
4
4
 
5
5
 
6
6
 
@@ -10,21 +10,21 @@ var _chunk63WKWOMOjs = require('../chunk-63WKWOMO.js');
10
10
 
11
11
 
12
12
 
13
- var _chunkYDNKDSSTjs = require('../chunk-YDNKDSST.js');
13
+ var _chunkIGFTD4HWjs = require('../chunk-IGFTD4HW.js');
14
14
 
15
15
  // src/accounts/index.ts
16
16
  var _bip32 = require('@scure/bip32');
17
17
 
18
18
  // src/accounts/generateMnemonic.ts
19
19
  var _bip39 = require('@scure/bip39');
20
- function generateMnemonic(wordlist10) {
21
- return _bip39.generateMnemonic.call(void 0, wordlist10);
20
+ function generateMnemonic(wordlist) {
21
+ return _bip39.generateMnemonic.call(void 0, wordlist);
22
22
  }
23
23
 
24
24
  // src/accounts/generatePrivateKey.ts
25
25
  var _secp256k1 = require('@noble/curves/secp256k1');
26
26
  function generatePrivateKey() {
27
- return _chunkYDNKDSSTjs.toHex.call(void 0, _secp256k1.secp256k1.utils.randomPrivateKey());
27
+ return _chunkIGFTD4HWjs.toHex.call(void 0, _secp256k1.secp256k1.utils.randomPrivateKey());
28
28
  }
29
29
 
30
30
  // src/accounts/privateKeyToAccount.ts
@@ -38,8 +38,8 @@ async function sign({
38
38
  }) {
39
39
  const { r, s, recovery } = _secp256k1.secp256k1.sign(hash.slice(2), privateKey.slice(2));
40
40
  return {
41
- r: _chunkYDNKDSSTjs.toHex.call(void 0, r),
42
- s: _chunkYDNKDSSTjs.toHex.call(void 0, s),
41
+ r: _chunkIGFTD4HWjs.toHex.call(void 0, r),
42
+ s: _chunkIGFTD4HWjs.toHex.call(void 0, s),
43
43
  v: recovery ? 28n : 27n
44
44
  };
45
45
  }
@@ -48,9 +48,9 @@ async function sign({
48
48
 
49
49
  function signatureToHex({ r, s, v }) {
50
50
  return `0x${new _secp256k1.secp256k1.Signature(
51
- _chunkYDNKDSSTjs.hexToBigInt.call(void 0, r),
52
- _chunkYDNKDSSTjs.hexToBigInt.call(void 0, s)
53
- ).toCompactHex()}${_chunkYDNKDSSTjs.toHex.call(void 0, v).slice(2)}`;
51
+ _chunkIGFTD4HWjs.hexToBigInt.call(void 0, r),
52
+ _chunkIGFTD4HWjs.hexToBigInt.call(void 0, s)
53
+ ).toCompactHex()}${_chunkIGFTD4HWjs.toHex.call(void 0, v).slice(2)}`;
54
54
  }
55
55
 
56
56
  // src/accounts/utils/signMessage.ts
@@ -58,7 +58,7 @@ async function signMessage({
58
58
  message,
59
59
  privateKey
60
60
  }) {
61
- const signature = await sign({ hash: _chunkYDNKDSSTjs.hashMessage.call(void 0, message), privateKey });
61
+ const signature = await sign({ hash: _chunkIGFTD4HWjs.hashMessage.call(void 0, message), privateKey });
62
62
  return signatureToHex(signature);
63
63
  }
64
64
 
@@ -68,10 +68,10 @@ async function signTransaction({
68
68
  transaction
69
69
  }) {
70
70
  const signature = await sign({
71
- hash: _chunkYDNKDSSTjs.keccak256.call(void 0, _chunkYDNKDSSTjs.serializeTransaction.call(void 0, transaction)),
71
+ hash: _chunkIGFTD4HWjs.keccak256.call(void 0, _chunkIGFTD4HWjs.serializeTransaction.call(void 0, transaction)),
72
72
  privateKey
73
73
  });
74
- return _chunkYDNKDSSTjs.serializeTransaction.call(void 0, transaction, signature);
74
+ return _chunkIGFTD4HWjs.serializeTransaction.call(void 0, transaction, signature);
75
75
  }
76
76
 
77
77
  // src/accounts/utils/signTypedData.ts
@@ -80,7 +80,7 @@ async function signTypedData({
80
80
  ...typedData
81
81
  }) {
82
82
  const signature = await sign({
83
- hash: _chunkYDNKDSSTjs.hashTypedData.call(void 0, typedData),
83
+ hash: _chunkIGFTD4HWjs.hashTypedData.call(void 0, typedData),
84
84
  privateKey
85
85
  });
86
86
  return signatureToHex(signature);
@@ -88,9 +88,9 @@ async function signTypedData({
88
88
 
89
89
  // src/accounts/privateKeyToAccount.ts
90
90
  function privateKeyToAccount(privateKey) {
91
- const publicKey = _chunkYDNKDSSTjs.toHex.call(void 0, _secp256k1.secp256k1.getPublicKey(privateKey.slice(2), false));
92
- const address = _chunkYDNKDSSTjs.publicKeyToAddress.call(void 0, publicKey);
93
- const account = _chunk63WKWOMOjs.toAccount.call(void 0, {
91
+ const publicKey = _chunkIGFTD4HWjs.toHex.call(void 0, _secp256k1.secp256k1.getPublicKey(privateKey.slice(2), false));
92
+ const address = _chunkIGFTD4HWjs.publicKeyToAddress.call(void 0, publicKey);
93
+ const account = _chunkEP6BQLGRjs.toAccount.call(void 0, {
94
94
  address,
95
95
  async signMessage({ message }) {
96
96
  return signMessage({ message, privateKey });
@@ -109,16 +109,64 @@ function privateKeyToAccount(privateKey) {
109
109
  };
110
110
  }
111
111
 
112
- // src/accounts/wordlists.ts
113
- var _czech = require('@scure/bip39/wordlists/czech');
114
- var _english = require('@scure/bip39/wordlists/english');
115
- var _french = require('@scure/bip39/wordlists/french');
116
- var _italian = require('@scure/bip39/wordlists/italian');
117
- var _japanese = require('@scure/bip39/wordlists/japanese');
118
- var _korean = require('@scure/bip39/wordlists/korean');
119
- var _simplifiedchinese = require('@scure/bip39/wordlists/simplified-chinese');
120
- var _spanish = require('@scure/bip39/wordlists/spanish');
121
- var _traditionalchinese = require('@scure/bip39/wordlists/traditional-chinese');
112
+ // src/accounts/hdKeyToAccount.ts
113
+ function hdKeyToAccount(hdKey_, { accountIndex = 0, addressIndex = 0, changeIndex = 0, path } = {}) {
114
+ const hdKey = hdKey_.derive(
115
+ path || `m/44'/60'/${accountIndex}'/${changeIndex}/${addressIndex}`
116
+ );
117
+ const account = privateKeyToAccount(_chunkIGFTD4HWjs.toHex.call(void 0, hdKey.privateKey));
118
+ return {
119
+ ...account,
120
+ getHdKey: () => hdKey,
121
+ source: "hd"
122
+ };
123
+ }
124
+
125
+ // src/accounts/mnemonicToAccount.ts
126
+
127
+
128
+ function mnemonicToAccount(mnemonic, opts = {}) {
129
+ const seed = _bip39.mnemonicToSeedSync.call(void 0, mnemonic);
130
+ return hdKeyToAccount(_bip32.HDKey.fromMasterSeed(seed), opts);
131
+ }
132
+
133
+ // src/accounts/wordlists/czech.ts
134
+ var _czechjs = require('@scure/bip39/wordlists/czech.js'); var _czechjs2 = _interopRequireDefault(_czechjs);
135
+ var czech = _czechjs2.default.wordlist;
136
+
137
+ // src/accounts/wordlists/english.ts
138
+ var _englishjs = require('@scure/bip39/wordlists/english.js'); var _englishjs2 = _interopRequireDefault(_englishjs);
139
+ var english = _englishjs2.default.wordlist;
140
+
141
+ // src/accounts/wordlists/french.ts
142
+ var _frenchjs = require('@scure/bip39/wordlists/french.js'); var _frenchjs2 = _interopRequireDefault(_frenchjs);
143
+ var french = _frenchjs2.default.wordlist;
144
+
145
+ // src/accounts/wordlists/italian.ts
146
+ var _italianjs = require('@scure/bip39/wordlists/italian.js'); var _italianjs2 = _interopRequireDefault(_italianjs);
147
+ var italian = _italianjs2.default.wordlist;
148
+
149
+ // src/accounts/wordlists/japanese.ts
150
+ var _japanesejs = require('@scure/bip39/wordlists/japanese.js'); var _japanesejs2 = _interopRequireDefault(_japanesejs);
151
+ var japanese = _japanesejs2.default.wordlist;
152
+
153
+ // src/accounts/wordlists/korean.ts
154
+ var _koreanjs = require('@scure/bip39/wordlists/korean.js'); var _koreanjs2 = _interopRequireDefault(_koreanjs);
155
+ var korean = _koreanjs2.default.wordlist;
156
+
157
+ // src/accounts/wordlists/simplifiedChinese.ts
158
+ var _simplifiedchinesejs = require('@scure/bip39/wordlists/simplified-chinese.js'); var _simplifiedchinesejs2 = _interopRequireDefault(_simplifiedchinesejs);
159
+ var simplifiedChinese = _simplifiedchinesejs2.default.wordlist;
160
+
161
+ // src/accounts/wordlists/spanish.ts
162
+ var _spanishjs = require('@scure/bip39/wordlists/spanish.js'); var _spanishjs2 = _interopRequireDefault(_spanishjs);
163
+ var spanish = _spanishjs2.default.wordlist;
164
+
165
+ // src/accounts/wordlists/traditionalChinese.ts
166
+ var _traditionalchinesejs = require('@scure/bip39/wordlists/traditional-chinese.js'); var _traditionalchinesejs2 = _interopRequireDefault(_traditionalchinesejs);
167
+ var traditionalChinese = _traditionalchinesejs2.default.wordlist;
168
+
169
+
122
170
 
123
171
 
124
172
 
@@ -138,5 +186,5 @@ var _traditionalchinese = require('@scure/bip39/wordlists/traditional-chinese');
138
186
 
139
187
 
140
188
 
141
- 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 = _chunkYDNKDSSTjs.parseAccount; exports.privateKeyToAccount = privateKeyToAccount; exports.publicKeyToAddress = _chunkYDNKDSSTjs.publicKeyToAddress; exports.signMessage = signMessage; exports.signTypedData = signTypedData; exports.simplifiedChinese = _simplifiedchinese.wordlist; exports.spanish = _spanish.wordlist; exports.toAccount = _chunk63WKWOMOjs.toAccount; exports.traditionalChinese = _traditionalchinese.wordlist;
189
+ exports.HDKey = _bip32.HDKey; exports.czech = czech; exports.english = english; exports.french = french; exports.generateMnemonic = generateMnemonic; exports.generatePrivateKey = generatePrivateKey; exports.hdKeyToAccount = hdKeyToAccount; exports.italian = italian; exports.japanese = japanese; exports.korean = korean; exports.mnemonicToAccount = mnemonicToAccount; exports.parseAccount = _chunkIGFTD4HWjs.parseAccount; exports.privateKeyToAccount = privateKeyToAccount; exports.publicKeyToAddress = _chunkIGFTD4HWjs.publicKeyToAddress; exports.signMessage = signMessage; exports.signTypedData = signTypedData; exports.simplifiedChinese = simplifiedChinese; exports.spanish = spanish; exports.toAccount = _chunkEP6BQLGRjs.toAccount; exports.traditionalChinese = traditionalChinese;
142
190
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/accounts/index.ts","../../src/accounts/generateMnemonic.ts","../../src/accounts/generatePrivateKey.ts","../../src/accounts/privateKeyToAccount.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","secp256k1"],"mappings":";;;;;;;;;;;;;;;AAAA,SAAS,aAAa;;;ACAtB,SAAS,oBAAoB,yBAAyB;AAS/C,SAAS,iBAAiBA,YAA4B;AAC3D,SAAO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,SAAS,oBAAoB,YAAoC;AACtE,QAAM,YAAY,MAAMA,WAAU,aAAa,WAAW,MAAM,CAAC,GAAG,KAAK,CAAC;AAC1E,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,aAAa;AACjC,aAAO,gBAAgB,EAAE,YAAY,YAAY,CAAC;AAAA,IACpD;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;AAAA,IACA,QAAQ;AAAA,EACV;AACF;;;AMxCA,SAAqB,gBAAa;AAClC,SAAqB,YAAZD,iBAA2B;AACpC,SAAqB,YAAZA,iBAA0B;AACnC,SAAqB,YAAZA,iBAA2B;AACpC,SAAqB,YAAZA,iBAA4B;AACrC,SAAqB,YAAZA,iBAA0B;AACnC,SAAqB,YAAZA,iBAAqC;AAC9C,SAAqB,YAAZA,iBAA2B;AACpC,SAAqB,YAAZA,iBAAsC","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 { secp256k1 } from '@noble/curves/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(secp256k1.utils.randomPrivateKey())\n}\n","import { secp256k1 } from '@noble/curves/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(secp256k1.getPublicKey(privateKey.slice(2), false))\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 { secp256k1 } from '@noble/curves/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 { r, s, recovery } = secp256k1.sign(hash.slice(2), privateKey.slice(2))\n return {\n r: toHex(r),\n s: toHex(s),\n v: recovery ? 28n : 27n,\n }\n}\n","import { secp256k1 } from '@noble/curves/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 secp256k1.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
+ {"version":3,"sources":["../../src/accounts/index.ts","../../src/accounts/generateMnemonic.ts","../../src/accounts/generatePrivateKey.ts","../../src/accounts/privateKeyToAccount.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/hdKeyToAccount.ts","../../src/accounts/mnemonicToAccount.ts","../../src/accounts/wordlists/czech.ts","../../src/accounts/wordlists/english.ts","../../src/accounts/wordlists/french.ts","../../src/accounts/wordlists/italian.ts","../../src/accounts/wordlists/japanese.ts","../../src/accounts/wordlists/korean.ts","../../src/accounts/wordlists/simplifiedChinese.ts","../../src/accounts/wordlists/spanish.ts","../../src/accounts/wordlists/traditionalChinese.ts"],"names":["HDKey","secp256k1","pkg"],"mappings":";;;;;;;;;;;;;;;AAAA,SAAS,SAAAA,cAAa;;;ACAtB,SAAS,oBAAoB,yBAAyB;AAS/C,SAAS,iBAAiB,UAA4B;AAC3D,SAAO,kBAAkB,QAAQ;AACnC;;;ACXA,SAAS,iBAAiB;AAUnB,SAAS,qBAA0B;AACxC,SAAO,MAAM,UAAU,MAAM,iBAAiB,CAAC;AACjD;;;ACZA,SAAS,aAAAC,kBAAiB;;;ACA1B,SAAS,aAAAA,kBAAiB;AAmB1B,eAAsB,KAAK;AAAA,EACzB;AAAA,EACA;AACF,GAA4C;AAC1C,QAAM,EAAE,GAAG,GAAG,SAAS,IAAIA,WAAU,KAAK,KAAK,MAAM,CAAC,GAAG,WAAW,MAAM,CAAC,CAAC;AAC5E,SAAO;AAAA,IACL,GAAG,MAAM,CAAC;AAAA,IACV,GAAG,MAAM,CAAC;AAAA,IACV,GAAG,WAAW,MAAM;AAAA,EACtB;AACF;;;AC7BA,SAAS,aAAAA,kBAAiB;AAKnB,SAAS,eAAe,EAAE,GAAG,GAAG,EAAE,GAAmB;AAC1D,SAAO,KAAK,IAAIA,WAAU;AAAA,IACxB,YAAY,CAAC;AAAA,IACb,YAAY,CAAC;AAAA,EACf,EAAE,aAAa,IAAI,MAAM,CAAC,EAAE,MAAM,CAAC;AACrC;;;ACSA,eAAsB,YAAY;AAAA,EAChC;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BAAoB,MAAM,MAAM,UAAW,CAAC;AAC5D,SAAO;AAAA,IACL,GAAG;AAAA,IACH,UAAU,MAAM;AAAA,IAChB,QAAQ;AAAA,EACV;AACF;;;ACxBA,SAAS,aAAa;AACtB,SAAS,0BAA0B;AAU5B,SAAS,kBACd,UACA,OAAkB,CAAC,GACR;AACX,QAAM,OAAO,mBAAmB,QAAQ;AACxC,SAAO,eAAe,MAAM,eAAe,IAAI,GAAG,IAAI;AACxD;;;ACjBA,OAAO,SAAS;AACT,IAAM,QAAQ,IAAI;;;ACDzB,OAAOC,UAAS;AACT,IAAM,UAAUA,KAAI;;;ACD3B,OAAOA,UAAS;AACT,IAAM,SAASA,KAAI;;;ACD1B,OAAOA,UAAS;AACT,IAAM,UAAUA,KAAI;;;ACD3B,OAAOA,UAAS;AACT,IAAM,WAAWA,KAAI;;;ACD5B,OAAOA,UAAS;AACT,IAAM,SAASA,KAAI;;;ACD1B,OAAOA,UAAS;AACT,IAAM,oBAAoBA,KAAI;;;ACDrC,OAAOA,UAAS;AACT,IAAM,UAAUA,KAAI;;;ACD3B,OAAOA,UAAS;AACT,IAAM,qBAAqBA,KAAI","sourcesContent":["import { HDKey } from '@scure/bip32'\nexport { HDKey }\n\nexport { generateMnemonic } from './generateMnemonic'\n\nexport { generatePrivateKey } from './generatePrivateKey'\n\nexport { hdKeyToAccount } from './hdKeyToAccount'\n\nexport { mnemonicToAccount } from './mnemonicToAccount'\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 { czech } from './wordlists/czech'\nexport { english } from './wordlists/english'\nexport { french } from './wordlists/french'\nexport { italian } from './wordlists/italian'\nexport { japanese } from './wordlists/japanese'\nexport { korean } from './wordlists/korean'\nexport { simplifiedChinese } from './wordlists/simplifiedChinese'\nexport { spanish } from './wordlists/spanish'\nexport { traditionalChinese } from './wordlists/traditionalChinese'\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 { secp256k1 } from '@noble/curves/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(secp256k1.utils.randomPrivateKey())\n}\n","import { secp256k1 } from '@noble/curves/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(secp256k1.getPublicKey(privateKey.slice(2), false))\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 { secp256k1 } from '@noble/curves/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 { r, s, recovery } = secp256k1.sign(hash.slice(2), privateKey.slice(2))\n return {\n r: toHex(r),\n s: toHex(s),\n v: recovery ? 28n : 27n,\n }\n}\n","import { secp256k1 } from '@noble/curves/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 secp256k1.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","import type { HDKey } from '@scure/bip32'\n\nimport { toHex } from '../utils'\nimport { privateKeyToAccount } from './privateKeyToAccount'\nimport type { HDAccount, HDOptions } from './types'\n\n/**\n * @description Creates an Account from a HD Key.\n *\n * @returns A HD Account.\n */\nexport function hdKeyToAccount(\n hdKey_: HDKey,\n { accountIndex = 0, addressIndex = 0, changeIndex = 0, path }: HDOptions = {},\n): HDAccount {\n const hdKey = hdKey_.derive(\n path || `m/44'/60'/${accountIndex}'/${changeIndex}/${addressIndex}`,\n )\n const account = privateKeyToAccount(toHex(hdKey.privateKey!))\n return {\n ...account,\n getHdKey: () => hdKey,\n source: 'hd',\n }\n}\n","import { HDKey } from '@scure/bip32'\nimport { mnemonicToSeedSync } from '@scure/bip39'\nimport { hdKeyToAccount } from './hdKeyToAccount'\n\nimport type { HDAccount, HDOptions } from './types'\n\n/**\n * @description Creates an Account from a mnemonic phrase.\n *\n * @returns A HD Account.\n */\nexport function mnemonicToAccount(\n mnemonic: string,\n opts: HDOptions = {},\n): HDAccount {\n const seed = mnemonicToSeedSync(mnemonic)\n return hdKeyToAccount(HDKey.fromMasterSeed(seed), opts)\n}\n","import pkg from '@scure/bip39/wordlists/czech.js'\nexport const czech = pkg.wordlist\n","import pkg from '@scure/bip39/wordlists/english.js'\nexport const english = pkg.wordlist\n","import pkg from '@scure/bip39/wordlists/french.js'\nexport const french = pkg.wordlist\n","import pkg from '@scure/bip39/wordlists/italian.js'\nexport const italian = pkg.wordlist\n","import pkg from '@scure/bip39/wordlists/japanese.js'\nexport const japanese = pkg.wordlist\n","import pkg from '@scure/bip39/wordlists/korean.js'\nexport const korean = pkg.wordlist\n","import pkg from '@scure/bip39/wordlists/simplified-chinese.js'\nexport const simplifiedChinese = pkg.wordlist\n","import pkg from '@scure/bip39/wordlists/spanish.js'\nexport const spanish = pkg.wordlist\n","import pkg from '@scure/bip39/wordlists/traditional-chinese.js'\nexport const traditionalChinese = pkg.wordlist\n"]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  toAccount
3
- } from "../chunk-KON3DHPC.mjs";
3
+ } from "../chunk-ZXUGY7ZA.mjs";
4
4
  import {
5
5
  hashMessage,
6
6
  hashTypedData,
@@ -10,15 +10,15 @@ import {
10
10
  publicKeyToAddress,
11
11
  serializeTransaction,
12
12
  toHex
13
- } from "../chunk-FSIBCQFR.mjs";
13
+ } from "../chunk-GJGV3W5S.mjs";
14
14
 
15
15
  // src/accounts/index.ts
16
- import { HDKey } from "@scure/bip32";
16
+ import { HDKey as HDKey2 } from "@scure/bip32";
17
17
 
18
18
  // src/accounts/generateMnemonic.ts
19
19
  import { generateMnemonic as generateMnemonic_ } from "@scure/bip39";
20
- function generateMnemonic(wordlist10) {
21
- return generateMnemonic_(wordlist10);
20
+ function generateMnemonic(wordlist) {
21
+ return generateMnemonic_(wordlist);
22
22
  }
23
23
 
24
24
  // src/accounts/generatePrivateKey.ts
@@ -109,34 +109,82 @@ function privateKeyToAccount(privateKey) {
109
109
  };
110
110
  }
111
111
 
112
- // src/accounts/wordlists.ts
113
- import { wordlist } from "@scure/bip39/wordlists/czech";
114
- import { wordlist as wordlist2 } from "@scure/bip39/wordlists/english";
115
- import { wordlist as wordlist3 } from "@scure/bip39/wordlists/french";
116
- import { wordlist as wordlist4 } from "@scure/bip39/wordlists/italian";
117
- import { wordlist as wordlist5 } from "@scure/bip39/wordlists/japanese";
118
- import { wordlist as wordlist6 } from "@scure/bip39/wordlists/korean";
119
- import { wordlist as wordlist7 } from "@scure/bip39/wordlists/simplified-chinese";
120
- import { wordlist as wordlist8 } from "@scure/bip39/wordlists/spanish";
121
- import { wordlist as wordlist9 } from "@scure/bip39/wordlists/traditional-chinese";
112
+ // src/accounts/hdKeyToAccount.ts
113
+ function hdKeyToAccount(hdKey_, { accountIndex = 0, addressIndex = 0, changeIndex = 0, path } = {}) {
114
+ const hdKey = hdKey_.derive(
115
+ path || `m/44'/60'/${accountIndex}'/${changeIndex}/${addressIndex}`
116
+ );
117
+ const account = privateKeyToAccount(toHex(hdKey.privateKey));
118
+ return {
119
+ ...account,
120
+ getHdKey: () => hdKey,
121
+ source: "hd"
122
+ };
123
+ }
124
+
125
+ // src/accounts/mnemonicToAccount.ts
126
+ import { HDKey } from "@scure/bip32";
127
+ import { mnemonicToSeedSync } from "@scure/bip39";
128
+ function mnemonicToAccount(mnemonic, opts = {}) {
129
+ const seed = mnemonicToSeedSync(mnemonic);
130
+ return hdKeyToAccount(HDKey.fromMasterSeed(seed), opts);
131
+ }
132
+
133
+ // src/accounts/wordlists/czech.ts
134
+ import pkg from "@scure/bip39/wordlists/czech.js";
135
+ var czech = pkg.wordlist;
136
+
137
+ // src/accounts/wordlists/english.ts
138
+ import pkg2 from "@scure/bip39/wordlists/english.js";
139
+ var english = pkg2.wordlist;
140
+
141
+ // src/accounts/wordlists/french.ts
142
+ import pkg3 from "@scure/bip39/wordlists/french.js";
143
+ var french = pkg3.wordlist;
144
+
145
+ // src/accounts/wordlists/italian.ts
146
+ import pkg4 from "@scure/bip39/wordlists/italian.js";
147
+ var italian = pkg4.wordlist;
148
+
149
+ // src/accounts/wordlists/japanese.ts
150
+ import pkg5 from "@scure/bip39/wordlists/japanese.js";
151
+ var japanese = pkg5.wordlist;
152
+
153
+ // src/accounts/wordlists/korean.ts
154
+ import pkg6 from "@scure/bip39/wordlists/korean.js";
155
+ var korean = pkg6.wordlist;
156
+
157
+ // src/accounts/wordlists/simplifiedChinese.ts
158
+ import pkg7 from "@scure/bip39/wordlists/simplified-chinese.js";
159
+ var simplifiedChinese = pkg7.wordlist;
160
+
161
+ // src/accounts/wordlists/spanish.ts
162
+ import pkg8 from "@scure/bip39/wordlists/spanish.js";
163
+ var spanish = pkg8.wordlist;
164
+
165
+ // src/accounts/wordlists/traditionalChinese.ts
166
+ import pkg9 from "@scure/bip39/wordlists/traditional-chinese.js";
167
+ var traditionalChinese = pkg9.wordlist;
122
168
  export {
123
- HDKey,
124
- wordlist as czech,
125
- wordlist2 as english,
126
- wordlist3 as french,
169
+ HDKey2 as HDKey,
170
+ czech,
171
+ english,
172
+ french,
127
173
  generateMnemonic,
128
174
  generatePrivateKey,
129
- wordlist4 as italian,
130
- wordlist5 as japanese,
131
- wordlist6 as korean,
175
+ hdKeyToAccount,
176
+ italian,
177
+ japanese,
178
+ korean,
179
+ mnemonicToAccount,
132
180
  parseAccount,
133
181
  privateKeyToAccount,
134
182
  publicKeyToAddress,
135
183
  signMessage,
136
184
  signTypedData,
137
- wordlist7 as simplifiedChinese,
138
- wordlist8 as spanish,
185
+ simplifiedChinese,
186
+ spanish,
139
187
  toAccount,
140
- wordlist9 as traditionalChinese
188
+ traditionalChinese
141
189
  };
142
190
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/accounts/index.ts","../../src/accounts/generateMnemonic.ts","../../src/accounts/generatePrivateKey.ts","../../src/accounts/privateKeyToAccount.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 { secp256k1 } from '@noble/curves/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(secp256k1.utils.randomPrivateKey())\n}\n","import { secp256k1 } from '@noble/curves/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(secp256k1.getPublicKey(privateKey.slice(2), false))\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 { secp256k1 } from '@noble/curves/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 { r, s, recovery } = secp256k1.sign(hash.slice(2), privateKey.slice(2))\n return {\n r: toHex(r),\n s: toHex(s),\n v: recovery ? 28n : 27n,\n }\n}\n","import { secp256k1 } from '@noble/curves/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 secp256k1.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":";;;;;;;;;;;;;;;AAAA,SAAS,aAAa;;;ACAtB,SAAS,oBAAoB,yBAAyB;AAS/C,SAAS,iBAAiBA,YAA4B;AAC3D,SAAO,kBAAkBA,UAAQ;AACnC;;;ACXA,SAAS,iBAAiB;AAUnB,SAAS,qBAA0B;AACxC,SAAO,MAAM,UAAU,MAAM,iBAAiB,CAAC;AACjD;;;ACZA,SAAS,aAAAC,kBAAiB;;;ACA1B,SAAS,aAAAC,kBAAiB;AAmB1B,eAAsB,KAAK;AAAA,EACzB;AAAA,EACA;AACF,GAA4C;AAC1C,QAAM,EAAE,GAAG,GAAG,SAAS,IAAIC,WAAU,KAAK,KAAK,MAAM,CAAC,GAAG,WAAW,MAAM,CAAC,CAAC;AAC5E,SAAO;AAAA,IACL,GAAG,MAAM,CAAC;AAAA,IACV,GAAG,MAAM,CAAC;AAAA,IACV,GAAG,WAAW,MAAM;AAAA,EACtB;AACF;;;AC7BA,SAAS,aAAAC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L,GAAG;AAAA,IACH;AAAA,IACA,QAAQ;AAAA,EACV;AACF;;;AMxCA,SAAqB,gBAAa;AAClC,SAAqB,YAAZC,iBAA2B;AACpC,SAAqB,YAAZA,iBAA0B;AACnC,SAAqB,YAAZA,iBAA2B;AACpC,SAAqB,YAAZA,iBAA4B;AACrC,SAAqB,YAAZA,iBAA0B;AACnC,SAAqB,YAAZA,iBAAqC;AAC9C,SAAqB,YAAZA,iBAA2B;AACpC,SAAqB,YAAZA,iBAAsC;","names":["wordlist","secp256k1","secp256k1","secp256k1","secp256k1","secp256k1","secp256k1","wordlist"]}
1
+ {"version":3,"sources":["../../src/accounts/index.ts","../../src/accounts/generateMnemonic.ts","../../src/accounts/generatePrivateKey.ts","../../src/accounts/privateKeyToAccount.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/hdKeyToAccount.ts","../../src/accounts/mnemonicToAccount.ts","../../src/accounts/wordlists/czech.ts","../../src/accounts/wordlists/english.ts","../../src/accounts/wordlists/french.ts","../../src/accounts/wordlists/italian.ts","../../src/accounts/wordlists/japanese.ts","../../src/accounts/wordlists/korean.ts","../../src/accounts/wordlists/simplifiedChinese.ts","../../src/accounts/wordlists/spanish.ts","../../src/accounts/wordlists/traditionalChinese.ts"],"sourcesContent":["import { HDKey } from '@scure/bip32'\nexport { HDKey }\n\nexport { generateMnemonic } from './generateMnemonic'\n\nexport { generatePrivateKey } from './generatePrivateKey'\n\nexport { hdKeyToAccount } from './hdKeyToAccount'\n\nexport { mnemonicToAccount } from './mnemonicToAccount'\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 { czech } from './wordlists/czech'\nexport { english } from './wordlists/english'\nexport { french } from './wordlists/french'\nexport { italian } from './wordlists/italian'\nexport { japanese } from './wordlists/japanese'\nexport { korean } from './wordlists/korean'\nexport { simplifiedChinese } from './wordlists/simplifiedChinese'\nexport { spanish } from './wordlists/spanish'\nexport { traditionalChinese } from './wordlists/traditionalChinese'\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 { secp256k1 } from '@noble/curves/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(secp256k1.utils.randomPrivateKey())\n}\n","import { secp256k1 } from '@noble/curves/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(secp256k1.getPublicKey(privateKey.slice(2), false))\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 { secp256k1 } from '@noble/curves/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 { r, s, recovery } = secp256k1.sign(hash.slice(2), privateKey.slice(2))\n return {\n r: toHex(r),\n s: toHex(s),\n v: recovery ? 28n : 27n,\n }\n}\n","import { secp256k1 } from '@noble/curves/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 secp256k1.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","import type { HDKey } from '@scure/bip32'\n\nimport { toHex } from '../utils'\nimport { privateKeyToAccount } from './privateKeyToAccount'\nimport type { HDAccount, HDOptions } from './types'\n\n/**\n * @description Creates an Account from a HD Key.\n *\n * @returns A HD Account.\n */\nexport function hdKeyToAccount(\n hdKey_: HDKey,\n { accountIndex = 0, addressIndex = 0, changeIndex = 0, path }: HDOptions = {},\n): HDAccount {\n const hdKey = hdKey_.derive(\n path || `m/44'/60'/${accountIndex}'/${changeIndex}/${addressIndex}`,\n )\n const account = privateKeyToAccount(toHex(hdKey.privateKey!))\n return {\n ...account,\n getHdKey: () => hdKey,\n source: 'hd',\n }\n}\n","import { HDKey } from '@scure/bip32'\nimport { mnemonicToSeedSync } from '@scure/bip39'\nimport { hdKeyToAccount } from './hdKeyToAccount'\n\nimport type { HDAccount, HDOptions } from './types'\n\n/**\n * @description Creates an Account from a mnemonic phrase.\n *\n * @returns A HD Account.\n */\nexport function mnemonicToAccount(\n mnemonic: string,\n opts: HDOptions = {},\n): HDAccount {\n const seed = mnemonicToSeedSync(mnemonic)\n return hdKeyToAccount(HDKey.fromMasterSeed(seed), opts)\n}\n","import pkg from '@scure/bip39/wordlists/czech.js'\nexport const czech = pkg.wordlist\n","import pkg from '@scure/bip39/wordlists/english.js'\nexport const english = pkg.wordlist\n","import pkg from '@scure/bip39/wordlists/french.js'\nexport const french = pkg.wordlist\n","import pkg from '@scure/bip39/wordlists/italian.js'\nexport const italian = pkg.wordlist\n","import pkg from '@scure/bip39/wordlists/japanese.js'\nexport const japanese = pkg.wordlist\n","import pkg from '@scure/bip39/wordlists/korean.js'\nexport const korean = pkg.wordlist\n","import pkg from '@scure/bip39/wordlists/simplified-chinese.js'\nexport const simplifiedChinese = pkg.wordlist\n","import pkg from '@scure/bip39/wordlists/spanish.js'\nexport const spanish = pkg.wordlist\n","import pkg from '@scure/bip39/wordlists/traditional-chinese.js'\nexport const traditionalChinese = pkg.wordlist\n"],"mappings":";;;;;;;;;;;;;;;AAAA,SAAS,SAAAA,cAAa;;;ACAtB,SAAS,oBAAoB,yBAAyB;AAS/C,SAAS,iBAAiB,UAA4B;AAC3D,SAAO,kBAAkB,QAAQ;AACnC;;;ACXA,SAAS,iBAAiB;AAUnB,SAAS,qBAA0B;AACxC,SAAO,MAAM,UAAU,MAAM,iBAAiB,CAAC;AACjD;;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UAAS;AACT,IAAM,UAAUA,KAAI;;;ACD3B,OAAOC,UAAS;AACT,IAAM,qBAAqBA,KAAI;","names":["HDKey","secp256k1","secp256k1","secp256k1","secp256k1","secp256k1","secp256k1","pkg","pkg","pkg","pkg","pkg","pkg","pkg","pkg"]}
package/dist/chains.d.ts CHANGED
@@ -891,9 +891,11 @@ declare const foundry: {
891
891
  readonly rpcUrls: {
892
892
  readonly default: {
893
893
  readonly http: readonly ["http://127.0.0.1:8545"];
894
+ readonly webSocket: readonly ["ws://127.0.0.1:8545"];
894
895
  };
895
896
  readonly public: {
896
897
  readonly http: readonly ["http://127.0.0.1:8545"];
898
+ readonly webSocket: readonly ["ws://127.0.0.1:8545"];
897
899
  };
898
900
  };
899
901
  };