viem 0.2.3 → 0.2.5
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 +2 -2
- package/dist/abi.mjs +1 -1
- package/dist/accounts/index.d.ts +10 -19
- package/dist/accounts/index.js +29 -38
- package/dist/accounts/index.js.map +1 -1
- package/dist/accounts/index.mjs +22 -31
- package/dist/accounts/index.mjs.map +1 -1
- package/dist/chains.js +89 -89
- package/dist/chains.mjs +1 -1
- package/dist/{chunk-ZM26BDGF.mjs → chunk-2QM6UMZ2.mjs} +8 -3
- package/dist/{chunk-ZM26BDGF.mjs.map → chunk-2QM6UMZ2.mjs.map} +1 -1
- package/dist/{chunk-TXGT3ARS.js → chunk-7MFQVE5P.js} +6 -6
- package/dist/{chunk-FYMFYRJQ.mjs → chunk-LLPICH7U.mjs} +2 -2
- package/dist/{chunk-E6JLGC6W.js → chunk-QWBI757J.js} +8 -3
- package/dist/chunk-QWBI757J.js.map +1 -0
- package/dist/contract.d.ts +1 -1
- package/dist/contract.js +2 -2
- package/dist/contract.mjs +1 -1
- package/dist/ens.d.ts +1 -1
- package/dist/ens.js +2 -2
- package/dist/ens.mjs +1 -1
- package/dist/ethers.js +4 -4
- package/dist/ethers.mjs +2 -2
- package/dist/{getEnsResolver-9e26c596.d.ts → getEnsResolver-ce85735b.d.ts} +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +94 -94
- package/dist/index.mjs +1 -1
- package/dist/{parseGwei-d2147f8b.d.ts → parseGwei-280a3ff7.d.ts} +1 -1
- package/dist/public.d.ts +1 -1
- package/dist/public.js +2 -2
- package/dist/public.mjs +1 -1
- package/dist/test.js +2 -2
- package/dist/test.mjs +1 -1
- package/dist/utils/index.d.ts +4 -4
- package/dist/utils/index.js +2 -2
- package/dist/utils/index.mjs +1 -1
- package/dist/wallet.d.ts +1 -1
- package/dist/wallet.js +2 -2
- package/dist/wallet.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-E6JLGC6W.js.map +0 -1
- /package/dist/{chunk-TXGT3ARS.js.map → chunk-7MFQVE5P.js.map} +0 -0
- /package/dist/{chunk-FYMFYRJQ.mjs.map → chunk-LLPICH7U.mjs.map} +0 -0
package/dist/abi.js
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
|
8
8
|
|
9
9
|
|
10
|
-
var
|
10
|
+
var _chunkQWBI757Jjs = require('./chunk-QWBI757J.js');
|
11
11
|
|
12
12
|
|
13
13
|
|
@@ -17,5 +17,5 @@ var _chunkE6JLGC6Wjs = require('./chunk-E6JLGC6W.js');
|
|
17
17
|
|
18
18
|
|
19
19
|
|
20
|
-
exports.decodeAbiParameters =
|
20
|
+
exports.decodeAbiParameters = _chunkQWBI757Jjs.decodeAbiParameters; exports.encodeAbiParameters = _chunkQWBI757Jjs.encodeAbiParameters; exports.encodePacked = _chunkQWBI757Jjs.encodePacked; exports.getAbiItem = _chunkQWBI757Jjs.getAbiItem; exports.parseAbi = _chunkQWBI757Jjs.parseAbi; exports.parseAbiItem = _chunkQWBI757Jjs.parseAbiItem; exports.parseAbiParameter = _chunkQWBI757Jjs.parseAbiParameter; exports.parseAbiParameters = _chunkQWBI757Jjs.parseAbiParameters;
|
21
21
|
//# sourceMappingURL=abi.js.map
|
package/dist/abi.mjs
CHANGED
package/dist/accounts/index.d.ts
CHANGED
@@ -5,6 +5,15 @@ import { b as HDOptions, H as HDAccount, P as PrivateKeyAccount, a as AccountSou
|
|
5
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';
|
6
6
|
import { Address, TypedData } from 'abitype';
|
7
7
|
export { p as parseAccount, a as publicKeyToAddress } from '../publicKeyToAddress-623eb398.js';
|
8
|
+
export { wordlist as czech } from '@scure/bip39/wordlists/czech.js';
|
9
|
+
export { wordlist as english } from '@scure/bip39/wordlists/english.js';
|
10
|
+
export { wordlist as french } from '@scure/bip39/wordlists/french.js';
|
11
|
+
export { wordlist as italian } from '@scure/bip39/wordlists/italian.js';
|
12
|
+
export { wordlist as japanese } from '@scure/bip39/wordlists/japanese.js';
|
13
|
+
export { wordlist as korean } from '@scure/bip39/wordlists/korean.js';
|
14
|
+
export { wordlist as simplifiedChinese } from '@scure/bip39/wordlists/simplified-chinese.js';
|
15
|
+
export { wordlist as spanish } from '@scure/bip39/wordlists/spanish.js';
|
16
|
+
export { wordlist as traditionalChinese } from '@scure/bip39/wordlists/traditional-chinese.js';
|
8
17
|
import '@wagmi/chains';
|
9
18
|
|
10
19
|
/**
|
@@ -84,22 +93,4 @@ declare function signTypedData<TTypedData extends TypedData | {
|
|
84
93
|
[key: string]: unknown;
|
85
94
|
}, TPrimaryType extends string = string>({ privateKey, ...typedData }: SignTypedDataParameters<TTypedData, TPrimaryType>): Promise<SignTypedDataReturnType>;
|
86
95
|
|
87
|
-
|
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 };
|
96
|
+
export { SignMessageParameters, SignMessageReturnType, SignTypedDataParameters, SignTypedDataReturnType, generateMnemonic, generatePrivateKey, hdKeyToAccount, mnemonicToAccount, privateKeyToAccount, signMessage, signTypedData, toAccount };
|
package/dist/accounts/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
2
2
|
|
3
|
-
var
|
3
|
+
var _chunk7MFQVE5Pjs = require('../chunk-7MFQVE5P.js');
|
4
4
|
|
5
5
|
|
6
6
|
|
@@ -10,21 +10,21 @@ var _chunkTXGT3ARSjs = require('../chunk-TXGT3ARS.js');
|
|
10
10
|
|
11
11
|
|
12
12
|
|
13
|
-
var
|
13
|
+
var _chunkQWBI757Jjs = require('../chunk-QWBI757J.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(
|
21
|
-
return _bip39.generateMnemonic.call(void 0,
|
20
|
+
function generateMnemonic(wordlist10) {
|
21
|
+
return _bip39.generateMnemonic.call(void 0, wordlist10);
|
22
22
|
}
|
23
23
|
|
24
24
|
// src/accounts/generatePrivateKey.ts
|
25
25
|
var _secp256k1 = require('@noble/curves/secp256k1');
|
26
26
|
function generatePrivateKey() {
|
27
|
-
return
|
27
|
+
return _chunkQWBI757Jjs.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:
|
42
|
-
s:
|
41
|
+
r: _chunkQWBI757Jjs.toHex.call(void 0, r),
|
42
|
+
s: _chunkQWBI757Jjs.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
|
-
|
52
|
-
|
53
|
-
).toCompactHex()}${
|
51
|
+
_chunkQWBI757Jjs.hexToBigInt.call(void 0, r),
|
52
|
+
_chunkQWBI757Jjs.hexToBigInt.call(void 0, s)
|
53
|
+
).toCompactHex()}${_chunkQWBI757Jjs.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:
|
61
|
+
const signature = await sign({ hash: _chunkQWBI757Jjs.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:
|
71
|
+
hash: _chunkQWBI757Jjs.keccak256.call(void 0, _chunkQWBI757Jjs.serializeTransaction.call(void 0, transaction)),
|
72
72
|
privateKey
|
73
73
|
});
|
74
|
-
return
|
74
|
+
return _chunkQWBI757Jjs.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:
|
83
|
+
hash: _chunkQWBI757Jjs.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 =
|
92
|
-
const address =
|
93
|
-
const account =
|
91
|
+
const publicKey = _chunkQWBI757Jjs.toHex.call(void 0, _secp256k1.secp256k1.getPublicKey(privateKey.slice(2), false));
|
92
|
+
const address = _chunkQWBI757Jjs.publicKeyToAddress.call(void 0, publicKey);
|
93
|
+
const account = _chunk7MFQVE5Pjs.toAccount.call(void 0, {
|
94
94
|
address,
|
95
95
|
async signMessage({ message }) {
|
96
96
|
return signMessage({ message, privateKey });
|
@@ -114,7 +114,7 @@ function hdKeyToAccount(hdKey_, { accountIndex = 0, addressIndex = 0, changeInde
|
|
114
114
|
const hdKey = hdKey_.derive(
|
115
115
|
path || `m/44'/60'/${accountIndex}'/${changeIndex}/${addressIndex}`
|
116
116
|
);
|
117
|
-
const account = privateKeyToAccount(
|
117
|
+
const account = privateKeyToAccount(_chunkQWBI757Jjs.toHex.call(void 0, hdKey.privateKey));
|
118
118
|
return {
|
119
119
|
...account,
|
120
120
|
getHdKey: () => hdKey,
|
@@ -131,40 +131,31 @@ function mnemonicToAccount(mnemonic, opts = {}) {
|
|
131
131
|
}
|
132
132
|
|
133
133
|
// src/accounts/wordlists/czech.ts
|
134
|
-
var _czechjs = require('@scure/bip39/wordlists/czech.js');
|
135
|
-
var czech = _czechjs2.default.wordlist;
|
134
|
+
var _czechjs = require('@scure/bip39/wordlists/czech.js');
|
136
135
|
|
137
136
|
// src/accounts/wordlists/english.ts
|
138
|
-
var _englishjs = require('@scure/bip39/wordlists/english.js');
|
139
|
-
var english = _englishjs2.default.wordlist;
|
137
|
+
var _englishjs = require('@scure/bip39/wordlists/english.js');
|
140
138
|
|
141
139
|
// src/accounts/wordlists/french.ts
|
142
|
-
var _frenchjs = require('@scure/bip39/wordlists/french.js');
|
143
|
-
var french = _frenchjs2.default.wordlist;
|
140
|
+
var _frenchjs = require('@scure/bip39/wordlists/french.js');
|
144
141
|
|
145
142
|
// src/accounts/wordlists/italian.ts
|
146
|
-
var _italianjs = require('@scure/bip39/wordlists/italian.js');
|
147
|
-
var italian = _italianjs2.default.wordlist;
|
143
|
+
var _italianjs = require('@scure/bip39/wordlists/italian.js');
|
148
144
|
|
149
145
|
// src/accounts/wordlists/japanese.ts
|
150
|
-
var _japanesejs = require('@scure/bip39/wordlists/japanese.js');
|
151
|
-
var japanese = _japanesejs2.default.wordlist;
|
146
|
+
var _japanesejs = require('@scure/bip39/wordlists/japanese.js');
|
152
147
|
|
153
148
|
// src/accounts/wordlists/korean.ts
|
154
|
-
var _koreanjs = require('@scure/bip39/wordlists/korean.js');
|
155
|
-
var korean = _koreanjs2.default.wordlist;
|
149
|
+
var _koreanjs = require('@scure/bip39/wordlists/korean.js');
|
156
150
|
|
157
151
|
// src/accounts/wordlists/simplifiedChinese.ts
|
158
|
-
var _simplifiedchinesejs = require('@scure/bip39/wordlists/simplified-chinese.js');
|
159
|
-
var simplifiedChinese = _simplifiedchinesejs2.default.wordlist;
|
152
|
+
var _simplifiedchinesejs = require('@scure/bip39/wordlists/simplified-chinese.js');
|
160
153
|
|
161
154
|
// src/accounts/wordlists/spanish.ts
|
162
|
-
var _spanishjs = require('@scure/bip39/wordlists/spanish.js');
|
163
|
-
var spanish = _spanishjs2.default.wordlist;
|
155
|
+
var _spanishjs = require('@scure/bip39/wordlists/spanish.js');
|
164
156
|
|
165
157
|
// src/accounts/wordlists/traditionalChinese.ts
|
166
|
-
var _traditionalchinesejs = require('@scure/bip39/wordlists/traditional-chinese.js');
|
167
|
-
var traditionalChinese = _traditionalchinesejs2.default.wordlist;
|
158
|
+
var _traditionalchinesejs = require('@scure/bip39/wordlists/traditional-chinese.js');
|
168
159
|
|
169
160
|
|
170
161
|
|
@@ -186,5 +177,5 @@ var traditionalChinese = _traditionalchinesejs2.default.wordlist;
|
|
186
177
|
|
187
178
|
|
188
179
|
|
189
|
-
exports.HDKey = _bip32.HDKey; exports.czech =
|
180
|
+
exports.HDKey = _bip32.HDKey; exports.czech = _czechjs.wordlist; exports.english = _englishjs.wordlist; exports.french = _frenchjs.wordlist; exports.generateMnemonic = generateMnemonic; exports.generatePrivateKey = generatePrivateKey; exports.hdKeyToAccount = hdKeyToAccount; exports.italian = _italianjs.wordlist; exports.japanese = _japanesejs.wordlist; exports.korean = _koreanjs.wordlist; exports.mnemonicToAccount = mnemonicToAccount; exports.parseAccount = _chunkQWBI757Jjs.parseAccount; exports.privateKeyToAccount = privateKeyToAccount; exports.publicKeyToAddress = _chunkQWBI757Jjs.publicKeyToAddress; exports.signMessage = signMessage; exports.signTypedData = signTypedData; exports.simplifiedChinese = _simplifiedchinesejs.wordlist; exports.spanish = _spanishjs.wordlist; exports.toAccount = _chunk7MFQVE5Pjs.toAccount; exports.traditionalChinese = _traditionalchinesejs.wordlist;
|
190
181
|
//# 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/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;AAmB1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AAqBA,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
|
+
{"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","wordlist","secp256k1"],"mappings":";;;;;;;;;;;;;;;AAAA,SAAS,SAAAA,cAAa;;;ACAtB,SAAS,oBAAoB,yBAAyB;AAS/C,SAAS,iBAAiBC,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,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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AA,EACF,CAAC;AAED,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,IACA,QAAQ;AAAA,EACV;AACF;;;AM7BO,SAAS,eACd,QACA,EAAE,eAAe,GAAG,eAAe,GAAG,cAAc,GAAG,KAAK,IAAe,CAAC,GACjE;AACX,QAAM,QAAQ,OAAO;AAAA,IACnB,QAAQ,aAAa,iBAAiB,eAAe;AAAA,EACvD;AACA,QAAM,UAAU,oBAAoB,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,SAAqB,gBAAa;;;ACAlC,SAAqB,YAAZD,iBAA2B;;;ACApC,SAAqB,YAAZA,iBAA0B;;;ACAnC,SAAqB,YAAZA,iBAA2B;;;ACApC,SAAqB,YAAZA,iBAA4B;;;ACArC,SAAqB,YAAZA,iBAA0B;;;ACAnC,SAAqB,YAAZA,iBAAqC;;;ACA9C,SAAqB,YAAZA,iBAA2B;;;ACApC,SAAqB,YAAZA,iBAAsC","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","export { wordlist as czech } from '@scure/bip39/wordlists/czech.js'\n","export { wordlist as english } from '@scure/bip39/wordlists/english.js'\n","export { wordlist as french } from '@scure/bip39/wordlists/french.js'\n","export { wordlist as italian } from '@scure/bip39/wordlists/italian.js'\n","export { wordlist as japanese } from '@scure/bip39/wordlists/japanese.js'\n","export { wordlist as korean } from '@scure/bip39/wordlists/korean.js'\n","export { wordlist as simplifiedChinese } from '@scure/bip39/wordlists/simplified-chinese.js'\n","export { wordlist as spanish } from '@scure/bip39/wordlists/spanish.js'\n","export { wordlist as traditionalChinese } from '@scure/bip39/wordlists/traditional-chinese.js'\n"]}
|
package/dist/accounts/index.mjs
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import {
|
2
2
|
toAccount
|
3
|
-
} from "../chunk-
|
3
|
+
} from "../chunk-LLPICH7U.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-
|
13
|
+
} from "../chunk-2QM6UMZ2.mjs";
|
14
14
|
|
15
15
|
// src/accounts/index.ts
|
16
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(
|
21
|
-
return generateMnemonic_(
|
20
|
+
function generateMnemonic(wordlist10) {
|
21
|
+
return generateMnemonic_(wordlist10);
|
22
22
|
}
|
23
23
|
|
24
24
|
// src/accounts/generatePrivateKey.ts
|
@@ -131,60 +131,51 @@ function mnemonicToAccount(mnemonic, opts = {}) {
|
|
131
131
|
}
|
132
132
|
|
133
133
|
// src/accounts/wordlists/czech.ts
|
134
|
-
import
|
135
|
-
var czech = pkg.wordlist;
|
134
|
+
import { wordlist } from "@scure/bip39/wordlists/czech.js";
|
136
135
|
|
137
136
|
// src/accounts/wordlists/english.ts
|
138
|
-
import
|
139
|
-
var english = pkg2.wordlist;
|
137
|
+
import { wordlist as wordlist2 } from "@scure/bip39/wordlists/english.js";
|
140
138
|
|
141
139
|
// src/accounts/wordlists/french.ts
|
142
|
-
import
|
143
|
-
var french = pkg3.wordlist;
|
140
|
+
import { wordlist as wordlist3 } from "@scure/bip39/wordlists/french.js";
|
144
141
|
|
145
142
|
// src/accounts/wordlists/italian.ts
|
146
|
-
import
|
147
|
-
var italian = pkg4.wordlist;
|
143
|
+
import { wordlist as wordlist4 } from "@scure/bip39/wordlists/italian.js";
|
148
144
|
|
149
145
|
// src/accounts/wordlists/japanese.ts
|
150
|
-
import
|
151
|
-
var japanese = pkg5.wordlist;
|
146
|
+
import { wordlist as wordlist5 } from "@scure/bip39/wordlists/japanese.js";
|
152
147
|
|
153
148
|
// src/accounts/wordlists/korean.ts
|
154
|
-
import
|
155
|
-
var korean = pkg6.wordlist;
|
149
|
+
import { wordlist as wordlist6 } from "@scure/bip39/wordlists/korean.js";
|
156
150
|
|
157
151
|
// src/accounts/wordlists/simplifiedChinese.ts
|
158
|
-
import
|
159
|
-
var simplifiedChinese = pkg7.wordlist;
|
152
|
+
import { wordlist as wordlist7 } from "@scure/bip39/wordlists/simplified-chinese.js";
|
160
153
|
|
161
154
|
// src/accounts/wordlists/spanish.ts
|
162
|
-
import
|
163
|
-
var spanish = pkg8.wordlist;
|
155
|
+
import { wordlist as wordlist8 } from "@scure/bip39/wordlists/spanish.js";
|
164
156
|
|
165
157
|
// src/accounts/wordlists/traditionalChinese.ts
|
166
|
-
import
|
167
|
-
var traditionalChinese = pkg9.wordlist;
|
158
|
+
import { wordlist as wordlist9 } from "@scure/bip39/wordlists/traditional-chinese.js";
|
168
159
|
export {
|
169
160
|
HDKey2 as HDKey,
|
170
|
-
czech,
|
171
|
-
english,
|
172
|
-
french,
|
161
|
+
wordlist as czech,
|
162
|
+
wordlist2 as english,
|
163
|
+
wordlist3 as french,
|
173
164
|
generateMnemonic,
|
174
165
|
generatePrivateKey,
|
175
166
|
hdKeyToAccount,
|
176
|
-
italian,
|
177
|
-
japanese,
|
178
|
-
korean,
|
167
|
+
wordlist4 as italian,
|
168
|
+
wordlist5 as japanese,
|
169
|
+
wordlist6 as korean,
|
179
170
|
mnemonicToAccount,
|
180
171
|
parseAccount,
|
181
172
|
privateKeyToAccount,
|
182
173
|
publicKeyToAddress,
|
183
174
|
signMessage,
|
184
175
|
signTypedData,
|
185
|
-
simplifiedChinese,
|
186
|
-
spanish,
|
176
|
+
wordlist7 as simplifiedChinese,
|
177
|
+
wordlist8 as spanish,
|
187
178
|
toAccount,
|
188
|
-
traditionalChinese
|
179
|
+
wordlist9 as traditionalChinese
|
189
180
|
};
|
190
181
|
//# 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/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;;;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,kBAAiB;AAKnB,SAAS,eAAe,EAAE,GAAG,GAAG,EAAE,GAAmB;AAC1D,SAAO,KAAK,IAAIC,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;AAAA,EACA;A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,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,OAAOC,UAAS;AACT,IAAM,SAASA,KAAI;;;ACD1B,OAAOC,UAAS;AACT,IAAM,UAAUA,KAAI;;;ACD3B,OAAOC,UAAS;AACT,IAAM,WAAWA,KAAI;;;ACD5B,OAAOC,UAAS;AACT,IAAM,SAASA,KAAI;;;ACD1B,OAAOC,UAAS;AACT,IAAM,oBAAoBA,KAAI;;;ACDrC,OAAOC,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"]}
|
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","export { wordlist as czech } from '@scure/bip39/wordlists/czech.js'\n","export { wordlist as english } from '@scure/bip39/wordlists/english.js'\n","export { wordlist as french } from '@scure/bip39/wordlists/french.js'\n","export { wordlist as italian } from '@scure/bip39/wordlists/italian.js'\n","export { wordlist as japanese } from '@scure/bip39/wordlists/japanese.js'\n","export { wordlist as korean } from '@scure/bip39/wordlists/korean.js'\n","export { wordlist as simplifiedChinese } from '@scure/bip39/wordlists/simplified-chinese.js'\n","export { wordlist as spanish } from '@scure/bip39/wordlists/spanish.js'\n","export { wordlist as traditionalChinese } from '@scure/bip39/wordlists/traditional-chinese.js'\n"],"mappings":";;;;;;;;;;;;;;;AAAA,SAAS,SAAAA,cAAa;;;ACAtB,SAAS,oBAAoB,yBAAyB;AAS/C,SAAS,iBAAiBC,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,kBAAiB;AAKnB,SAAS,eAAe,EAAE,GAAG,GAAG,EAAE,GAAmB;AAC1D,SAAO,KAAK,IAAIC,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;AAAA,EACA;AACF,GAA0D;AACxD,QAAM,YAAY,MAAM,KAAK,EAAE,MAAM,YAAY,OAAO,GAAG,WAAW,CAAC;AACvE,SAAO,eAAe,SAAS;AACjC;;;ACDA,eAAsB,gBAEpB;AAAA,EACA;AAAA,EACA;AACF,GAEE;AACA,QAAM,YAAY,MAAM,KAAK;AAAA,IAC3B,MAAM,UAAU,qBAAqB,WAAW,CAAC;AAAA,IACjD;AAAA,EACF,CAAC;AACD,SAAO,qBAAqB,aAAa,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Aa;;;ACAlC,SAAqB,YAAZC,iBAA2B;;;ACApC,SAAqB,YAAZC,iBAA0B;;;ACAnC,SAAqB,YAAZC,iBAA2B;;;ACApC,SAAqB,YAAZC,iBAA4B;;;ACArC,SAAqB,YAAZC,iBAA0B;;;ACAnC,SAAqB,YAAZC,iBAAqC;;;ACA9C,SAAqB,YAAZC,iBAA2B;;;ACApC,SAAqB,YAAZC,iBAAsC;","names":["HDKey","wordlist","secp256k1","secp256k1","secp256k1","secp256k1","secp256k1","secp256k1","wordlist","wordlist","wordlist","wordlist","wordlist","wordlist","wordlist","wordlist"]}
|