viem 0.2.1 → 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 +2 -2
- package/dist/abi.mjs +1 -1
- package/dist/accounts/index.d.ts +19 -10
- package/dist/accounts/index.js +55 -30
- package/dist/accounts/index.js.map +1 -1
- package/dist/accounts/index.mjs +48 -23
- package/dist/accounts/index.mjs.map +1 -1
- package/dist/chains.d.ts +2 -0
- package/dist/chains.js +89 -89
- package/dist/chains.mjs +1 -1
- package/dist/{chunk-4EJIKB23.js → chunk-EP6BQLGR.js} +6 -6
- package/dist/{chunk-LEU2ZGMI.mjs → chunk-GJGV3W5S.mjs} +11 -12
- package/dist/chunk-GJGV3W5S.mjs.map +1 -0
- package/dist/{chunk-2DDJFGFE.js → chunk-IGFTD4HW.js} +11 -12
- package/dist/chunk-IGFTD4HW.js.map +1 -0
- package/dist/{chunk-YCI363JZ.mjs → chunk-ZXUGY7ZA.mjs} +2 -2
- package/dist/contract.js +2 -2
- package/dist/contract.mjs +1 -1
- package/dist/ens.js +5 -5
- package/dist/ens.js.map +1 -1
- package/dist/ens.mjs +3 -3
- package/dist/ens.mjs.map +1 -1
- package/dist/ethers.js +4 -4
- package/dist/ethers.mjs +2 -2
- package/dist/index.js +94 -94
- package/dist/index.mjs +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.js +2 -2
- package/dist/utils/index.mjs +1 -1
- package/dist/wallet.js +2 -2
- package/dist/wallet.mjs +1 -1
- package/package.json +10 -11
- package/dist/chunk-2DDJFGFE.js.map +0 -1
- package/dist/chunk-LEU2ZGMI.mjs.map +0 -1
- /package/dist/{chunk-4EJIKB23.js.map → chunk-EP6BQLGR.js.map} +0 -0
- /package/dist/{chunk-YCI363JZ.mjs.map → chunk-ZXUGY7ZA.mjs.map} +0 -0
package/dist/abi.js
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
|
8
8
|
|
9
9
|
|
10
|
-
var
|
10
|
+
var _chunkIGFTD4HWjs = require('./chunk-IGFTD4HW.js');
|
11
11
|
|
12
12
|
|
13
13
|
|
@@ -17,5 +17,5 @@ var _chunk2DDJFGFEjs = require('./chunk-2DDJFGFE.js');
|
|
17
17
|
|
18
18
|
|
19
19
|
|
20
|
-
exports.decodeAbiParameters =
|
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
package/dist/accounts/index.d.ts
CHANGED
@@ -5,15 +5,6 @@ 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';
|
9
|
-
export { wordlist as english } from '@scure/bip39/wordlists/english';
|
10
|
-
export { wordlist as french } from '@scure/bip39/wordlists/french';
|
11
|
-
export { wordlist as italian } from '@scure/bip39/wordlists/italian';
|
12
|
-
export { wordlist as japanese } from '@scure/bip39/wordlists/japanese';
|
13
|
-
export { wordlist as korean } from '@scure/bip39/wordlists/korean';
|
14
|
-
export { wordlist as simplifiedChinese } from '@scure/bip39/wordlists/simplified-chinese';
|
15
|
-
export { wordlist as spanish } from '@scure/bip39/wordlists/spanish';
|
16
|
-
export { wordlist as traditionalChinese } from '@scure/bip39/wordlists/traditional-chinese';
|
17
8
|
import '@wagmi/chains';
|
18
9
|
|
19
10
|
/**
|
@@ -93,4 +84,22 @@ declare function signTypedData<TTypedData extends TypedData | {
|
|
93
84
|
[key: string]: unknown;
|
94
85
|
}, TPrimaryType extends string = string>({ privateKey, ...typedData }: SignTypedDataParameters<TTypedData, TPrimaryType>): Promise<SignTypedDataReturnType>;
|
95
86
|
|
96
|
-
|
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 };
|
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}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
2
2
|
|
3
|
-
var
|
3
|
+
var _chunkEP6BQLGRjs = require('../chunk-EP6BQLGR.js');
|
4
4
|
|
5
5
|
|
6
6
|
|
@@ -10,21 +10,21 @@ var _chunk4EJIKB23js = require('../chunk-4EJIKB23.js');
|
|
10
10
|
|
11
11
|
|
12
12
|
|
13
|
-
var
|
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(
|
21
|
-
return _bip39.generateMnemonic.call(void 0,
|
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
|
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:
|
42
|
-
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
|
-
|
52
|
-
|
53
|
-
).toCompactHex()}${
|
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:
|
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:
|
71
|
+
hash: _chunkIGFTD4HWjs.keccak256.call(void 0, _chunkIGFTD4HWjs.serializeTransaction.call(void 0, transaction)),
|
72
72
|
privateKey
|
73
73
|
});
|
74
|
-
return
|
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:
|
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 =
|
92
|
-
const address =
|
93
|
-
const account =
|
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 });
|
@@ -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(_chunkIGFTD4HWjs.toHex.call(void 0, hdKey.privateKey));
|
118
118
|
return {
|
119
119
|
...account,
|
120
120
|
getHdKey: () => hdKey,
|
@@ -130,24 +130,41 @@ function mnemonicToAccount(mnemonic, opts = {}) {
|
|
130
130
|
return hdKeyToAccount(_bip32.HDKey.fromMasterSeed(seed), opts);
|
131
131
|
}
|
132
132
|
|
133
|
-
// src/accounts/wordlists.ts
|
134
|
-
var
|
135
|
-
var
|
136
|
-
var _french = require('@scure/bip39/wordlists/french');
|
137
|
-
var _italian = require('@scure/bip39/wordlists/italian');
|
138
|
-
var _japanese = require('@scure/bip39/wordlists/japanese');
|
139
|
-
var _korean = require('@scure/bip39/wordlists/korean');
|
140
|
-
var _simplifiedchinese = require('@scure/bip39/wordlists/simplified-chinese');
|
141
|
-
var _spanish = require('@scure/bip39/wordlists/spanish');
|
142
|
-
var _traditionalchinese = require('@scure/bip39/wordlists/traditional-chinese');
|
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;
|
143
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;
|
144
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;
|
145
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;
|
146
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;
|
147
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;
|
148
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;
|
149
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;
|
150
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;
|
151
168
|
|
152
169
|
|
153
170
|
|
@@ -161,5 +178,13 @@ var _traditionalchinese = require('@scure/bip39/wordlists/traditional-chinese');
|
|
161
178
|
|
162
179
|
|
163
180
|
|
164
|
-
|
181
|
+
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
|
188
|
+
|
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;
|
165
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/hdKeyToAccount.ts","../../src/accounts/mnemonicToAccount.ts","../../src/accounts/wordlists.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,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ACA,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;;;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;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'\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 {\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","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'\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","../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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"]}
|
package/dist/accounts/index.mjs
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import {
|
2
2
|
toAccount
|
3
|
-
} from "../chunk-
|
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-
|
13
|
+
} from "../chunk-GJGV3W5S.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(wordlist) {
|
21
|
+
return generateMnemonic_(wordlist);
|
22
22
|
}
|
23
23
|
|
24
24
|
// src/accounts/generatePrivateKey.ts
|
@@ -130,36 +130,61 @@ function mnemonicToAccount(mnemonic, opts = {}) {
|
|
130
130
|
return hdKeyToAccount(HDKey.fromMasterSeed(seed), opts);
|
131
131
|
}
|
132
132
|
|
133
|
-
// src/accounts/wordlists.ts
|
134
|
-
import
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
import
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
import
|
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;
|
143
168
|
export {
|
144
169
|
HDKey2 as HDKey,
|
145
|
-
|
146
|
-
|
147
|
-
|
170
|
+
czech,
|
171
|
+
english,
|
172
|
+
french,
|
148
173
|
generateMnemonic,
|
149
174
|
generatePrivateKey,
|
150
175
|
hdKeyToAccount,
|
151
|
-
|
152
|
-
|
153
|
-
|
176
|
+
italian,
|
177
|
+
japanese,
|
178
|
+
korean,
|
154
179
|
mnemonicToAccount,
|
155
180
|
parseAccount,
|
156
181
|
privateKeyToAccount,
|
157
182
|
publicKeyToAddress,
|
158
183
|
signMessage,
|
159
184
|
signTypedData,
|
160
|
-
|
161
|
-
|
185
|
+
simplifiedChinese,
|
186
|
+
spanish,
|
162
187
|
toAccount,
|
163
|
-
|
188
|
+
traditionalChinese
|
164
189
|
};
|
165
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/hdKeyToAccount.ts","../../src/accounts/mnemonicToAccount.ts","../../src/accounts/wordlists.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 {\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","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'\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,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,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AO;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;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":["HDKey","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;;;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,eA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AAa;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"]}
|
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
|
};
|