viem 0.1.23 → 0.2.0-0-2-0.20230328T054201
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/accounts/package.json +4 -0
- package/dist/abi.d.ts +3 -3
- package/dist/abi.js +2 -2
- package/dist/abi.mjs +1 -1
- package/dist/accounts/index.d.ts +90 -0
- package/dist/accounts/index.js +152 -0
- package/dist/accounts/index.js.map +1 -0
- package/dist/accounts/index.mjs +152 -0
- package/dist/accounts/index.mjs.map +1 -0
- package/dist/{chain-ec8c485d.d.ts → chain-40443542.d.ts} +1 -1
- package/dist/{chain-1b53ef88.d.ts → chain-4af995bf.d.ts} +77 -36
- package/dist/chains.d.ts +3 -3
- package/dist/chains.js +63 -63
- package/dist/chains.mjs +1 -1
- package/dist/chunk-43HQD3IL.js +31 -0
- package/dist/chunk-43HQD3IL.js.map +1 -0
- package/dist/{chunk-HRVPAYH7.mjs → chunk-DFMQLPHS.mjs} +2 -2
- package/dist/chunk-DFMQLPHS.mjs.map +1 -0
- package/dist/{chunk-66PXETQB.js → chunk-FZPFAAOJ.js} +19 -19
- package/dist/chunk-FZPFAAOJ.js.map +1 -0
- package/dist/{chunk-JG6MI5ZV.mjs → chunk-HYEOQX7O.mjs} +1106 -199
- package/dist/chunk-HYEOQX7O.mjs.map +1 -0
- package/dist/{chunk-Z54YSSBJ.js → chunk-OW7TKT7L.js} +1168 -261
- package/dist/chunk-OW7TKT7L.js.map +1 -0
- package/dist/chunk-UK6FAD4V.mjs +31 -0
- package/dist/chunk-UK6FAD4V.mjs.map +1 -0
- package/dist/contract.d.ts +9 -7
- package/dist/contract.js +2 -2
- package/dist/contract.mjs +1 -1
- package/dist/{createClient-a28317a9.d.ts → createClient-1f19be8d.d.ts} +24 -10
- package/dist/{createPublicClient-b250a534.d.ts → createPublicClient-fd8b1349.d.ts} +229 -242
- package/dist/{eip1193-4f4e240c.d.ts → eip1193-210ab776.d.ts} +1 -1
- package/dist/{encodeFunctionResult-1f324375.d.ts → encodeFunctionResult-a252fba1.d.ts} +1 -1
- package/dist/{encodePacked-d5d5264a.d.ts → encodePacked-a9464e97.d.ts} +1 -1
- package/dist/ens.d.ts +6 -4
- package/dist/ens.js +3 -3
- package/dist/ens.mjs +2 -2
- package/dist/ethers.d.ts +5 -6
- package/dist/ethers.js +7 -5
- package/dist/ethers.js.map +1 -1
- package/dist/ethers.mjs +7 -5
- package/dist/ethers.mjs.map +1 -1
- package/dist/{formatAbiItem-15e8817d.d.ts → formatAbiItem-6ed70dbd.d.ts} +1 -1
- package/dist/{getAbiItem-3e809ff9.d.ts → getAbiItem-1ff0f41a.d.ts} +1 -1
- package/dist/index.d.ts +22 -14
- package/dist/index.js +136 -101
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +78 -43
- package/dist/index.mjs.map +1 -1
- package/dist/parseAccount-8e131c73.d.ts +6 -0
- package/dist/{parseGwei-bd0eea6c.d.ts → parseGwei-5e2a8e87.d.ts} +95 -15
- package/dist/public.d.ts +6 -4
- package/dist/public.js +2 -2
- package/dist/public.mjs +1 -1
- package/dist/test-e28db435.d.ts +198 -0
- package/dist/test.d.ts +11 -11
- package/dist/test.js +2 -2
- package/dist/test.mjs +1 -1
- package/dist/typedData-848139b1.d.ts +93 -0
- package/dist/utils/index.d.ts +22 -30
- package/dist/utils/index.js +26 -2
- package/dist/utils/index.mjs +29 -5
- package/dist/wallet.d.ts +6 -4
- package/dist/wallet.js +2 -2
- package/dist/wallet.mjs +1 -1
- package/dist/window.d.ts +2 -2
- package/package.json +10 -2
- package/dist/chunk-66PXETQB.js.map +0 -1
- package/dist/chunk-HRVPAYH7.mjs.map +0 -1
- package/dist/chunk-JG6MI5ZV.mjs.map +0 -1
- package/dist/chunk-Z54YSSBJ.js.map +0 -1
- package/dist/test-2bd23d7e.d.ts +0 -205
package/dist/abi.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
export { ParseAbi, ParseAbiItem, ParseAbiParameter, ParseAbiParameters, parseAbi, parseAbiItem, parseAbiParameter, parseAbiParameters } from 'abitype';
|
2
|
-
export { D as DecodeAbiParametersReturnType, E as EncodeAbiParametersReturnType, G as GetAbiItemParameters, d as decodeAbiParameters, e as encodeAbiParameters, g as getAbiItem } from './getAbiItem-
|
3
|
-
export { e as encodePacked } from './encodePacked-
|
4
|
-
import './chain-
|
2
|
+
export { D as DecodeAbiParametersReturnType, E as EncodeAbiParametersReturnType, G as GetAbiItemParameters, d as decodeAbiParameters, e as encodeAbiParameters, g as getAbiItem } from './getAbiItem-1ff0f41a.js';
|
3
|
+
export { e as encodePacked } from './encodePacked-a9464e97.js';
|
4
|
+
import './chain-4af995bf.js';
|
5
5
|
import '@wagmi/chains';
|
package/dist/abi.js
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
|
8
8
|
|
9
9
|
|
10
|
-
var
|
10
|
+
var _chunkOW7TKT7Ljs = require('./chunk-OW7TKT7L.js');
|
11
11
|
|
12
12
|
|
13
13
|
|
@@ -17,5 +17,5 @@ var _chunkZ54YSSBJjs = require('./chunk-Z54YSSBJ.js');
|
|
17
17
|
|
18
18
|
|
19
19
|
|
20
|
-
exports.decodeAbiParameters =
|
20
|
+
exports.decodeAbiParameters = _chunkOW7TKT7Ljs.decodeAbiParameters; exports.encodeAbiParameters = _chunkOW7TKT7Ljs.encodeAbiParameters; exports.encodePacked = _chunkOW7TKT7Ljs.encodePacked; exports.getAbiItem = _chunkOW7TKT7Ljs.getAbiItem; exports.parseAbi = _chunkOW7TKT7Ljs.parseAbi; exports.parseAbiItem = _chunkOW7TKT7Ljs.parseAbiItem; exports.parseAbiParameter = _chunkOW7TKT7Ljs.parseAbiParameter; exports.parseAbiParameters = _chunkOW7TKT7Ljs.parseAbiParameters;
|
21
21
|
//# sourceMappingURL=abi.js.map
|
package/dist/abi.mjs
CHANGED
@@ -0,0 +1,90 @@
|
|
1
|
+
export { HDKey } from '@scure/bip32';
|
2
|
+
import { H as Hex } from '../chain-4af995bf.js';
|
3
|
+
import { P as PrivateKeyAccount, a as AccountSource, J as JsonRpcAccount, C as CustomSource, L as LocalAccount, T as TypedDataDefinition } from '../typedData-848139b1.js';
|
4
|
+
export { A as Account, a as AccountSource, C as CustomSource, H as HDAccount, b as HDOptions, J as JsonRpcAccount, L as LocalAccount, P as PrivateKeyAccount } from '../typedData-848139b1.js';
|
5
|
+
import { Address, TypedData } from 'abitype';
|
6
|
+
export { p as parseAccount } from '../parseAccount-8e131c73.js';
|
7
|
+
export { wordlist as czech } from '@scure/bip39/wordlists/czech';
|
8
|
+
export { wordlist as english } from '@scure/bip39/wordlists/english';
|
9
|
+
export { wordlist as french } from '@scure/bip39/wordlists/french';
|
10
|
+
export { wordlist as italian } from '@scure/bip39/wordlists/italian';
|
11
|
+
export { wordlist as japanese } from '@scure/bip39/wordlists/japanese';
|
12
|
+
export { wordlist as korean } from '@scure/bip39/wordlists/korean';
|
13
|
+
export { wordlist as simplifiedChinese } from '@scure/bip39/wordlists/simplified-chinese';
|
14
|
+
export { wordlist as spanish } from '@scure/bip39/wordlists/spanish';
|
15
|
+
export { wordlist as traditionalChinese } from '@scure/bip39/wordlists/traditional-chinese';
|
16
|
+
import '@wagmi/chains';
|
17
|
+
|
18
|
+
/**
|
19
|
+
* @description Generates a random mnemonic phrase with a given wordlist.
|
20
|
+
*
|
21
|
+
* @param wordlist The wordlist to use for generating the mnemonic phrase.
|
22
|
+
*
|
23
|
+
* @returns A randomly generated mnemonic phrase.
|
24
|
+
*/
|
25
|
+
declare function generateMnemonic(wordlist: string[]): string;
|
26
|
+
|
27
|
+
/**
|
28
|
+
* @description Generates a random private key.
|
29
|
+
*
|
30
|
+
* @returns A randomly generated private key.
|
31
|
+
*/
|
32
|
+
declare function generatePrivateKey(): Hex;
|
33
|
+
|
34
|
+
/**
|
35
|
+
* @description Creates an Account from a private key.
|
36
|
+
*
|
37
|
+
* @returns A Private Key Account.
|
38
|
+
*/
|
39
|
+
declare function privateKeyToAccount(privateKey: Hex): PrivateKeyAccount;
|
40
|
+
|
41
|
+
type GetAccountReturnType<TAccountSource extends AccountSource> = (TAccountSource extends Address ? JsonRpcAccount : never) | (TAccountSource extends CustomSource ? LocalAccount : never);
|
42
|
+
/**
|
43
|
+
* @description Creates an Account from a custom signing implementation.
|
44
|
+
*
|
45
|
+
* @returns A Local Account.
|
46
|
+
*/
|
47
|
+
declare function toAccount<TAccountSource extends AccountSource>(source: TAccountSource): GetAccountReturnType<TAccountSource>;
|
48
|
+
|
49
|
+
/**
|
50
|
+
* @description Converts an ECDSA public key to an address.
|
51
|
+
*
|
52
|
+
* @param publicKey The public key to convert.
|
53
|
+
*
|
54
|
+
* @returns The address.
|
55
|
+
*/
|
56
|
+
declare function publicKeyToAddress(publicKey: Hex): Address;
|
57
|
+
|
58
|
+
type SignMessageParameters = {
|
59
|
+
/** The message to sign. */
|
60
|
+
message: string;
|
61
|
+
/** The private key to sign with. */
|
62
|
+
privateKey: Hex;
|
63
|
+
};
|
64
|
+
type SignMessageReturnType = Hex;
|
65
|
+
/**
|
66
|
+
* @description Calculates an Ethereum-specific signature in [EIP-191 format](https://eips.ethereum.org/EIPS/eip-191):
|
67
|
+
* `keccak256("\x19Ethereum Signed Message:\n" + len(message) + message))`.
|
68
|
+
*
|
69
|
+
* @returns The signature.
|
70
|
+
*/
|
71
|
+
declare function signMessage({ message, privateKey, }: SignMessageParameters): Promise<SignMessageReturnType>;
|
72
|
+
|
73
|
+
type SignTypedDataParameters<TTypedData extends TypedData | {
|
74
|
+
[key: string]: unknown;
|
75
|
+
} = TypedData, TPrimaryType extends string = string> = TypedDataDefinition<TTypedData, TPrimaryType> & {
|
76
|
+
/** The private key to sign with. */
|
77
|
+
privateKey: Hex;
|
78
|
+
};
|
79
|
+
type SignTypedDataReturnType = Hex;
|
80
|
+
/**
|
81
|
+
* @description Signs typed data and calculates an Ethereum-specific signature in [EIP-191 format](https://eips.ethereum.org/EIPS/eip-191):
|
82
|
+
* `keccak256("\x19Ethereum Signed Message:\n" + len(message) + message))`.
|
83
|
+
*
|
84
|
+
* @returns The signature.
|
85
|
+
*/
|
86
|
+
declare function signTypedData<TTypedData extends TypedData | {
|
87
|
+
[key: string]: unknown;
|
88
|
+
}, TPrimaryType extends string = string>({ privateKey, ...typedData }: SignTypedDataParameters<TTypedData, TPrimaryType>): Promise<SignTypedDataReturnType>;
|
89
|
+
|
90
|
+
export { SignMessageParameters, SignMessageReturnType, SignTypedDataParameters, SignTypedDataReturnType, generateMnemonic, generatePrivateKey, privateKeyToAccount, publicKeyToAddress, signMessage, signTypedData, toAccount };
|
@@ -0,0 +1,152 @@
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
2
|
+
|
3
|
+
var _chunk43HQD3ILjs = require('../chunk-43HQD3IL.js');
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
var _chunkOW7TKT7Ljs = require('../chunk-OW7TKT7L.js');
|
14
|
+
|
15
|
+
// src/accounts/index.ts
|
16
|
+
var _bip32 = require('@scure/bip32');
|
17
|
+
|
18
|
+
// src/accounts/generateMnemonic.ts
|
19
|
+
var _bip39 = require('@scure/bip39');
|
20
|
+
function generateMnemonic(wordlist10) {
|
21
|
+
return _bip39.generateMnemonic.call(void 0, wordlist10);
|
22
|
+
}
|
23
|
+
|
24
|
+
// src/accounts/generatePrivateKey.ts
|
25
|
+
var _secp256k1 = require('@noble/secp256k1');
|
26
|
+
function generatePrivateKey() {
|
27
|
+
return _chunkOW7TKT7Ljs.toHex.call(void 0, _secp256k1.utils.randomPrivateKey());
|
28
|
+
}
|
29
|
+
|
30
|
+
// src/accounts/privateKeyToAccount.ts
|
31
|
+
|
32
|
+
|
33
|
+
// src/accounts/utils/publicKeyToAddress.ts
|
34
|
+
function publicKeyToAddress(publicKey) {
|
35
|
+
const address = _chunkOW7TKT7Ljs.keccak256.call(void 0, `0x${publicKey.substring(4)}`).substring(26);
|
36
|
+
return _chunkOW7TKT7Ljs.checksumAddress.call(void 0, `0x${address}`);
|
37
|
+
}
|
38
|
+
|
39
|
+
// src/accounts/utils/sign.ts
|
40
|
+
|
41
|
+
async function sign({
|
42
|
+
hash,
|
43
|
+
privateKey
|
44
|
+
}) {
|
45
|
+
const [sigBytes, recId] = await _secp256k1.sign.call(void 0, hash.slice(2), privateKey.slice(2), {
|
46
|
+
canonical: true,
|
47
|
+
recovered: true
|
48
|
+
});
|
49
|
+
const sig = _secp256k1.Signature.fromHex(sigBytes);
|
50
|
+
return {
|
51
|
+
r: _chunkOW7TKT7Ljs.toHex.call(void 0, sig.r),
|
52
|
+
s: _chunkOW7TKT7Ljs.toHex.call(void 0, sig.s),
|
53
|
+
v: recId ? 28n : 27n
|
54
|
+
};
|
55
|
+
}
|
56
|
+
|
57
|
+
// src/accounts/utils/signatureToHex.ts
|
58
|
+
|
59
|
+
function signatureToHex({ r, s, v }) {
|
60
|
+
return `0x${new (0, _secp256k1.Signature)(
|
61
|
+
_chunkOW7TKT7Ljs.hexToBigInt.call(void 0, r),
|
62
|
+
_chunkOW7TKT7Ljs.hexToBigInt.call(void 0, s)
|
63
|
+
).toCompactHex()}${_chunkOW7TKT7Ljs.toHex.call(void 0, v).slice(2)}`;
|
64
|
+
}
|
65
|
+
|
66
|
+
// src/accounts/utils/signMessage.ts
|
67
|
+
async function signMessage({
|
68
|
+
message,
|
69
|
+
privateKey
|
70
|
+
}) {
|
71
|
+
const signature = await sign({ hash: _chunkOW7TKT7Ljs.hashMessage.call(void 0, message), privateKey });
|
72
|
+
return signatureToHex(signature);
|
73
|
+
}
|
74
|
+
|
75
|
+
// src/accounts/utils/signTransaction.ts
|
76
|
+
async function signTransaction({
|
77
|
+
privateKey,
|
78
|
+
transaction
|
79
|
+
}) {
|
80
|
+
const signature = await sign({
|
81
|
+
hash: _chunkOW7TKT7Ljs.keccak256.call(void 0, _chunkOW7TKT7Ljs.serializeTransaction.call(void 0, transaction)),
|
82
|
+
privateKey
|
83
|
+
});
|
84
|
+
return _chunkOW7TKT7Ljs.serializeTransaction.call(void 0, transaction, signature);
|
85
|
+
}
|
86
|
+
|
87
|
+
// src/accounts/utils/signTypedData.ts
|
88
|
+
async function signTypedData({
|
89
|
+
privateKey,
|
90
|
+
...typedData
|
91
|
+
}) {
|
92
|
+
const signature = await sign({
|
93
|
+
hash: _chunkOW7TKT7Ljs.hashTypedData.call(void 0, typedData),
|
94
|
+
privateKey
|
95
|
+
});
|
96
|
+
return signatureToHex(signature);
|
97
|
+
}
|
98
|
+
|
99
|
+
// src/accounts/privateKeyToAccount.ts
|
100
|
+
function privateKeyToAccount(privateKey) {
|
101
|
+
const publicKey = _chunkOW7TKT7Ljs.toHex.call(void 0, _secp256k1.getPublicKey.call(void 0, privateKey.slice(2)));
|
102
|
+
const address = publicKeyToAddress(publicKey);
|
103
|
+
const account = _chunk43HQD3ILjs.toAccount.call(void 0, {
|
104
|
+
address,
|
105
|
+
async signMessage({ message }) {
|
106
|
+
return signMessage({ message, privateKey });
|
107
|
+
},
|
108
|
+
async signTransaction(transaction) {
|
109
|
+
return signTransaction({ privateKey, transaction });
|
110
|
+
},
|
111
|
+
async signTypedData(typedData) {
|
112
|
+
return signTypedData({ ...typedData, privateKey });
|
113
|
+
}
|
114
|
+
});
|
115
|
+
return {
|
116
|
+
...account,
|
117
|
+
publicKey,
|
118
|
+
source: "privateKey"
|
119
|
+
};
|
120
|
+
}
|
121
|
+
|
122
|
+
// src/accounts/wordlists.ts
|
123
|
+
var _czech = require('@scure/bip39/wordlists/czech');
|
124
|
+
var _english = require('@scure/bip39/wordlists/english');
|
125
|
+
var _french = require('@scure/bip39/wordlists/french');
|
126
|
+
var _italian = require('@scure/bip39/wordlists/italian');
|
127
|
+
var _japanese = require('@scure/bip39/wordlists/japanese');
|
128
|
+
var _korean = require('@scure/bip39/wordlists/korean');
|
129
|
+
var _simplifiedchinese = require('@scure/bip39/wordlists/simplified-chinese');
|
130
|
+
var _spanish = require('@scure/bip39/wordlists/spanish');
|
131
|
+
var _traditionalchinese = require('@scure/bip39/wordlists/traditional-chinese');
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
exports.HDKey = _bip32.HDKey; exports.czech = _czech.wordlist; exports.english = _english.wordlist; exports.french = _french.wordlist; exports.generateMnemonic = generateMnemonic; exports.generatePrivateKey = generatePrivateKey; exports.italian = _italian.wordlist; exports.japanese = _japanese.wordlist; exports.korean = _korean.wordlist; exports.parseAccount = _chunkOW7TKT7Ljs.parseAccount; exports.privateKeyToAccount = privateKeyToAccount; exports.publicKeyToAddress = publicKeyToAddress; exports.signMessage = signMessage; exports.signTypedData = signTypedData; exports.simplifiedChinese = _simplifiedchinese.wordlist; exports.spanish = _spanish.wordlist; exports.toAccount = _chunk43HQD3ILjs.toAccount; exports.traditionalChinese = _traditionalchinese.wordlist;
|
152
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../src/accounts/index.ts","../../src/accounts/generateMnemonic.ts","../../src/accounts/generatePrivateKey.ts","../../src/accounts/privateKeyToAccount.ts","../../src/accounts/utils/publicKeyToAddress.ts","../../src/accounts/utils/sign.ts","../../src/accounts/utils/signatureToHex.ts","../../src/accounts/utils/signMessage.ts","../../src/accounts/utils/signTransaction.ts","../../src/accounts/utils/signTypedData.ts","../../src/accounts/wordlists.ts"],"names":["wordlist","Signature_"],"mappings":"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","sourcesContent":["import { HDKey } from '@scure/bip32'\n\nexport { HDKey }\n\nexport { generateMnemonic } from './generateMnemonic'\n\nexport { generatePrivateKey } from './generatePrivateKey'\n\nexport { privateKeyToAccount } from './privateKeyToAccount'\n\nexport { toAccount } from './toAccount'\n\nexport type {\n Account,\n AccountSource,\n CustomSource,\n HDOptions,\n JsonRpcAccount,\n LocalAccount,\n HDAccount,\n PrivateKeyAccount,\n} from './types'\n\nexport type {\n SignMessageParameters,\n SignMessageReturnType,\n SignTypedDataParameters,\n SignTypedDataReturnType,\n} from './utils'\nexport {\n parseAccount,\n publicKeyToAddress,\n signMessage,\n signTypedData,\n} from './utils'\n\nexport {\n czech,\n english,\n french,\n italian,\n japanese,\n korean,\n simplifiedChinese,\n spanish,\n traditionalChinese,\n} from './wordlists'\n","import { generateMnemonic as generateMnemonic_ } from '@scure/bip39'\n\n/**\n * @description Generates a random mnemonic phrase with a given wordlist.\n *\n * @param wordlist The wordlist to use for generating the mnemonic phrase.\n *\n * @returns A randomly generated mnemonic phrase.\n */\nexport function generateMnemonic(wordlist: string[]): string {\n return generateMnemonic_(wordlist)\n}\n","import { utils } from '@noble/secp256k1'\n\nimport type { Hex } from '../types'\nimport { toHex } from '../utils'\n\n/**\n * @description Generates a random private key.\n *\n * @returns A randomly generated private key.\n */\nexport function generatePrivateKey(): Hex {\n return toHex(utils.randomPrivateKey())\n}\n","import { getPublicKey } from '@noble/secp256k1'\n\nimport type { Hex } from '../types'\nimport { toHex } from '../utils'\nimport {\n publicKeyToAddress,\n signMessage,\n signTransaction,\n signTypedData,\n} from './utils'\nimport { toAccount } from './toAccount'\nimport type { PrivateKeyAccount } from './types'\n\n/**\n * @description Creates an Account from a private key.\n *\n * @returns A Private Key Account.\n */\nexport function privateKeyToAccount(privateKey: Hex): PrivateKeyAccount {\n const publicKey = toHex(getPublicKey(privateKey.slice(2)))\n const address = publicKeyToAddress(publicKey)\n\n const account = toAccount({\n address,\n async signMessage({ message }) {\n return signMessage({ message, privateKey })\n },\n async signTransaction(transaction) {\n return signTransaction({ privateKey, transaction })\n },\n async signTypedData(typedData) {\n return signTypedData({ ...typedData, privateKey })\n },\n })\n\n return {\n ...account,\n publicKey,\n source: 'privateKey',\n }\n}\n","import type { Address, Hex } from '../../types'\nimport { keccak256 } from '../../utils'\nimport { checksumAddress } from '../../utils/address'\n\n/**\n * @description Converts an ECDSA public key to an address.\n *\n * @param publicKey The public key to convert.\n *\n * @returns The address.\n */\nexport function publicKeyToAddress(publicKey: Hex): Address {\n const address = keccak256(`0x${publicKey.substring(4)}`).substring(26)\n return checksumAddress(`0x${address}`) as Address\n}\n","import { sign as sign_, Signature as Signature_ } from '@noble/secp256k1'\n\nimport type { Hex, Signature } from '../../types'\nimport { toHex } from '../../utils'\n\nexport type SignParameters = {\n hash: Hex\n privateKey: Hex\n}\nexport type SignReturnType = Signature\n\n/**\n * @description Signs a hash with a given private key.\n *\n * @param hash The hash to sign.\n * @param privateKey The private key to sign with.\n *\n * @returns The signature.\n */\nexport async function sign({\n hash,\n privateKey,\n}: SignParameters): Promise<SignReturnType> {\n const [sigBytes, recId] = await sign_(hash.slice(2), privateKey.slice(2), {\n canonical: true,\n recovered: true,\n })\n const sig = Signature_.fromHex(sigBytes)\n return {\n r: toHex(sig.r),\n s: toHex(sig.s),\n v: recId ? 28n : 27n,\n }\n}\n","import { Signature as Signature_ } from '@noble/secp256k1'\n\nimport type { Hex, Signature } from '../../types'\nimport { hexToBigInt, toHex } from '../../utils'\n\nexport function signatureToHex({ r, s, v }: Signature): Hex {\n return `0x${new Signature_(\n hexToBigInt(r),\n hexToBigInt(s),\n ).toCompactHex()}${toHex(v).slice(2)}`\n}\n","import type { Hex } from '../../types'\nimport { hashMessage } from '../../utils'\nimport { sign } from './sign'\nimport { signatureToHex } from './signatureToHex'\n\nexport type SignMessageParameters = {\n /** The message to sign. */\n message: string\n /** The private key to sign with. */\n privateKey: Hex\n}\nexport type SignMessageReturnType = Hex\n\n/**\n * @description Calculates an Ethereum-specific signature in [EIP-191 format](https://eips.ethereum.org/EIPS/eip-191):\n * `keccak256(\"\\x19Ethereum Signed Message:\\n\" + len(message) + message))`.\n *\n * @returns The signature.\n */\nexport async function signMessage({\n message,\n privateKey,\n}: SignMessageParameters): Promise<SignMessageReturnType> {\n const signature = await sign({ hash: hashMessage(message), privateKey })\n return signatureToHex(signature)\n}\n","import type {\n Hex,\n TransactionSerializable,\n TransactionSerialized,\n TransactionType,\n} from '../../types'\nimport {\n GetTransactionType,\n keccak256,\n serializeTransaction,\n} from '../../utils'\nimport { sign } from './sign'\n\nexport type SignTransactionArgs<\n TTransactionSerializable extends TransactionSerializable = TransactionSerializable,\n> = {\n privateKey: Hex\n transaction: TTransactionSerializable\n}\nexport type SignTransactionReturnType<\n TTransactionSerializable extends TransactionSerializable = TransactionSerializable,\n TTransactionType extends TransactionType = GetTransactionType<TTransactionSerializable>,\n> = TransactionSerialized<TTransactionType>\n\nexport async function signTransaction<\n TTransactionSerializable extends TransactionSerializable,\n>({\n privateKey,\n transaction,\n}: SignTransactionArgs<TTransactionSerializable>): Promise<\n SignTransactionReturnType<TTransactionSerializable>\n> {\n const signature = await sign({\n hash: keccak256(serializeTransaction(transaction)),\n privateKey,\n })\n return serializeTransaction(transaction, signature)\n}\n","import type { TypedData } from 'abitype'\n\nimport type { Hex, TypedDataDefinition } from '../../types'\nimport { HashTypedDataParameters, hashTypedData } from '../../utils'\nimport { sign } from './sign'\nimport { signatureToHex } from './signatureToHex'\n\nexport type SignTypedDataParameters<\n TTypedData extends TypedData | { [key: string]: unknown } = TypedData,\n TPrimaryType extends string = string,\n> = TypedDataDefinition<TTypedData, TPrimaryType> & {\n /** The private key to sign with. */\n privateKey: Hex\n}\n\nexport type SignTypedDataReturnType = Hex\n\n/**\n * @description Signs typed data and calculates an Ethereum-specific signature in [EIP-191 format](https://eips.ethereum.org/EIPS/eip-191):\n * `keccak256(\"\\x19Ethereum Signed Message:\\n\" + len(message) + message))`.\n *\n * @returns The signature.\n */\nexport async function signTypedData<\n TTypedData extends TypedData | { [key: string]: unknown },\n TPrimaryType extends string = string,\n>({\n privateKey,\n ...typedData\n}: SignTypedDataParameters<\n TTypedData,\n TPrimaryType\n>): Promise<SignTypedDataReturnType> {\n const signature = await sign({\n hash: hashTypedData(typedData as HashTypedDataParameters),\n privateKey,\n })\n return signatureToHex(signature)\n}\n","export { wordlist as czech } from '@scure/bip39/wordlists/czech'\nexport { wordlist as english } from '@scure/bip39/wordlists/english'\nexport { wordlist as french } from '@scure/bip39/wordlists/french'\nexport { wordlist as italian } from '@scure/bip39/wordlists/italian'\nexport { wordlist as japanese } from '@scure/bip39/wordlists/japanese'\nexport { wordlist as korean } from '@scure/bip39/wordlists/korean'\nexport { wordlist as simplifiedChinese } from '@scure/bip39/wordlists/simplified-chinese'\nexport { wordlist as spanish } from '@scure/bip39/wordlists/spanish'\nexport { wordlist as traditionalChinese } from '@scure/bip39/wordlists/traditional-chinese'\n"]}
|
@@ -0,0 +1,152 @@
|
|
1
|
+
import {
|
2
|
+
toAccount
|
3
|
+
} from "../chunk-UK6FAD4V.mjs";
|
4
|
+
import {
|
5
|
+
checksumAddress,
|
6
|
+
hashMessage,
|
7
|
+
hashTypedData,
|
8
|
+
hexToBigInt,
|
9
|
+
keccak256,
|
10
|
+
parseAccount,
|
11
|
+
serializeTransaction,
|
12
|
+
toHex
|
13
|
+
} from "../chunk-HYEOQX7O.mjs";
|
14
|
+
|
15
|
+
// src/accounts/index.ts
|
16
|
+
import { HDKey } from "@scure/bip32";
|
17
|
+
|
18
|
+
// src/accounts/generateMnemonic.ts
|
19
|
+
import { generateMnemonic as generateMnemonic_ } from "@scure/bip39";
|
20
|
+
function generateMnemonic(wordlist10) {
|
21
|
+
return generateMnemonic_(wordlist10);
|
22
|
+
}
|
23
|
+
|
24
|
+
// src/accounts/generatePrivateKey.ts
|
25
|
+
import { utils } from "@noble/secp256k1";
|
26
|
+
function generatePrivateKey() {
|
27
|
+
return toHex(utils.randomPrivateKey());
|
28
|
+
}
|
29
|
+
|
30
|
+
// src/accounts/privateKeyToAccount.ts
|
31
|
+
import { getPublicKey } from "@noble/secp256k1";
|
32
|
+
|
33
|
+
// src/accounts/utils/publicKeyToAddress.ts
|
34
|
+
function publicKeyToAddress(publicKey) {
|
35
|
+
const address = keccak256(`0x${publicKey.substring(4)}`).substring(26);
|
36
|
+
return checksumAddress(`0x${address}`);
|
37
|
+
}
|
38
|
+
|
39
|
+
// src/accounts/utils/sign.ts
|
40
|
+
import { sign as sign_, Signature as Signature_ } from "@noble/secp256k1";
|
41
|
+
async function sign({
|
42
|
+
hash,
|
43
|
+
privateKey
|
44
|
+
}) {
|
45
|
+
const [sigBytes, recId] = await sign_(hash.slice(2), privateKey.slice(2), {
|
46
|
+
canonical: true,
|
47
|
+
recovered: true
|
48
|
+
});
|
49
|
+
const sig = Signature_.fromHex(sigBytes);
|
50
|
+
return {
|
51
|
+
r: toHex(sig.r),
|
52
|
+
s: toHex(sig.s),
|
53
|
+
v: recId ? 28n : 27n
|
54
|
+
};
|
55
|
+
}
|
56
|
+
|
57
|
+
// src/accounts/utils/signatureToHex.ts
|
58
|
+
import { Signature as Signature_2 } from "@noble/secp256k1";
|
59
|
+
function signatureToHex({ r, s, v }) {
|
60
|
+
return `0x${new Signature_2(
|
61
|
+
hexToBigInt(r),
|
62
|
+
hexToBigInt(s)
|
63
|
+
).toCompactHex()}${toHex(v).slice(2)}`;
|
64
|
+
}
|
65
|
+
|
66
|
+
// src/accounts/utils/signMessage.ts
|
67
|
+
async function signMessage({
|
68
|
+
message,
|
69
|
+
privateKey
|
70
|
+
}) {
|
71
|
+
const signature = await sign({ hash: hashMessage(message), privateKey });
|
72
|
+
return signatureToHex(signature);
|
73
|
+
}
|
74
|
+
|
75
|
+
// src/accounts/utils/signTransaction.ts
|
76
|
+
async function signTransaction({
|
77
|
+
privateKey,
|
78
|
+
transaction
|
79
|
+
}) {
|
80
|
+
const signature = await sign({
|
81
|
+
hash: keccak256(serializeTransaction(transaction)),
|
82
|
+
privateKey
|
83
|
+
});
|
84
|
+
return serializeTransaction(transaction, signature);
|
85
|
+
}
|
86
|
+
|
87
|
+
// src/accounts/utils/signTypedData.ts
|
88
|
+
async function signTypedData({
|
89
|
+
privateKey,
|
90
|
+
...typedData
|
91
|
+
}) {
|
92
|
+
const signature = await sign({
|
93
|
+
hash: hashTypedData(typedData),
|
94
|
+
privateKey
|
95
|
+
});
|
96
|
+
return signatureToHex(signature);
|
97
|
+
}
|
98
|
+
|
99
|
+
// src/accounts/privateKeyToAccount.ts
|
100
|
+
function privateKeyToAccount(privateKey) {
|
101
|
+
const publicKey = toHex(getPublicKey(privateKey.slice(2)));
|
102
|
+
const address = publicKeyToAddress(publicKey);
|
103
|
+
const account = toAccount({
|
104
|
+
address,
|
105
|
+
async signMessage({ message }) {
|
106
|
+
return signMessage({ message, privateKey });
|
107
|
+
},
|
108
|
+
async signTransaction(transaction) {
|
109
|
+
return signTransaction({ privateKey, transaction });
|
110
|
+
},
|
111
|
+
async signTypedData(typedData) {
|
112
|
+
return signTypedData({ ...typedData, privateKey });
|
113
|
+
}
|
114
|
+
});
|
115
|
+
return {
|
116
|
+
...account,
|
117
|
+
publicKey,
|
118
|
+
source: "privateKey"
|
119
|
+
};
|
120
|
+
}
|
121
|
+
|
122
|
+
// src/accounts/wordlists.ts
|
123
|
+
import { wordlist } from "@scure/bip39/wordlists/czech";
|
124
|
+
import { wordlist as wordlist2 } from "@scure/bip39/wordlists/english";
|
125
|
+
import { wordlist as wordlist3 } from "@scure/bip39/wordlists/french";
|
126
|
+
import { wordlist as wordlist4 } from "@scure/bip39/wordlists/italian";
|
127
|
+
import { wordlist as wordlist5 } from "@scure/bip39/wordlists/japanese";
|
128
|
+
import { wordlist as wordlist6 } from "@scure/bip39/wordlists/korean";
|
129
|
+
import { wordlist as wordlist7 } from "@scure/bip39/wordlists/simplified-chinese";
|
130
|
+
import { wordlist as wordlist8 } from "@scure/bip39/wordlists/spanish";
|
131
|
+
import { wordlist as wordlist9 } from "@scure/bip39/wordlists/traditional-chinese";
|
132
|
+
export {
|
133
|
+
HDKey,
|
134
|
+
wordlist as czech,
|
135
|
+
wordlist2 as english,
|
136
|
+
wordlist3 as french,
|
137
|
+
generateMnemonic,
|
138
|
+
generatePrivateKey,
|
139
|
+
wordlist4 as italian,
|
140
|
+
wordlist5 as japanese,
|
141
|
+
wordlist6 as korean,
|
142
|
+
parseAccount,
|
143
|
+
privateKeyToAccount,
|
144
|
+
publicKeyToAddress,
|
145
|
+
signMessage,
|
146
|
+
signTypedData,
|
147
|
+
wordlist7 as simplifiedChinese,
|
148
|
+
wordlist8 as spanish,
|
149
|
+
toAccount,
|
150
|
+
wordlist9 as traditionalChinese
|
151
|
+
};
|
152
|
+
//# sourceMappingURL=index.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../src/accounts/index.ts","../../src/accounts/generateMnemonic.ts","../../src/accounts/generatePrivateKey.ts","../../src/accounts/privateKeyToAccount.ts","../../src/accounts/utils/publicKeyToAddress.ts","../../src/accounts/utils/sign.ts","../../src/accounts/utils/signatureToHex.ts","../../src/accounts/utils/signMessage.ts","../../src/accounts/utils/signTransaction.ts","../../src/accounts/utils/signTypedData.ts","../../src/accounts/wordlists.ts"],"sourcesContent":["import { HDKey } from '@scure/bip32'\n\nexport { HDKey }\n\nexport { generateMnemonic } from './generateMnemonic'\n\nexport { generatePrivateKey } from './generatePrivateKey'\n\nexport { privateKeyToAccount } from './privateKeyToAccount'\n\nexport { toAccount } from './toAccount'\n\nexport type {\n Account,\n AccountSource,\n CustomSource,\n HDOptions,\n JsonRpcAccount,\n LocalAccount,\n HDAccount,\n PrivateKeyAccount,\n} from './types'\n\nexport type {\n SignMessageParameters,\n SignMessageReturnType,\n SignTypedDataParameters,\n SignTypedDataReturnType,\n} from './utils'\nexport {\n parseAccount,\n publicKeyToAddress,\n signMessage,\n signTypedData,\n} from './utils'\n\nexport {\n czech,\n english,\n french,\n italian,\n japanese,\n korean,\n simplifiedChinese,\n spanish,\n traditionalChinese,\n} from './wordlists'\n","import { generateMnemonic as generateMnemonic_ } from '@scure/bip39'\n\n/**\n * @description Generates a random mnemonic phrase with a given wordlist.\n *\n * @param wordlist The wordlist to use for generating the mnemonic phrase.\n *\n * @returns A randomly generated mnemonic phrase.\n */\nexport function generateMnemonic(wordlist: string[]): string {\n return generateMnemonic_(wordlist)\n}\n","import { utils } from '@noble/secp256k1'\n\nimport type { Hex } from '../types'\nimport { toHex } from '../utils'\n\n/**\n * @description Generates a random private key.\n *\n * @returns A randomly generated private key.\n */\nexport function generatePrivateKey(): Hex {\n return toHex(utils.randomPrivateKey())\n}\n","import { getPublicKey } from '@noble/secp256k1'\n\nimport type { Hex } from '../types'\nimport { toHex } from '../utils'\nimport {\n publicKeyToAddress,\n signMessage,\n signTransaction,\n signTypedData,\n} from './utils'\nimport { toAccount } from './toAccount'\nimport type { PrivateKeyAccount } from './types'\n\n/**\n * @description Creates an Account from a private key.\n *\n * @returns A Private Key Account.\n */\nexport function privateKeyToAccount(privateKey: Hex): PrivateKeyAccount {\n const publicKey = toHex(getPublicKey(privateKey.slice(2)))\n const address = publicKeyToAddress(publicKey)\n\n const account = toAccount({\n address,\n async signMessage({ message }) {\n return signMessage({ message, privateKey })\n },\n async signTransaction(transaction) {\n return signTransaction({ privateKey, transaction })\n },\n async signTypedData(typedData) {\n return signTypedData({ ...typedData, privateKey })\n },\n })\n\n return {\n ...account,\n publicKey,\n source: 'privateKey',\n }\n}\n","import type { Address, Hex } from '../../types'\nimport { keccak256 } from '../../utils'\nimport { checksumAddress } from '../../utils/address'\n\n/**\n * @description Converts an ECDSA public key to an address.\n *\n * @param publicKey The public key to convert.\n *\n * @returns The address.\n */\nexport function publicKeyToAddress(publicKey: Hex): Address {\n const address = keccak256(`0x${publicKey.substring(4)}`).substring(26)\n return checksumAddress(`0x${address}`) as Address\n}\n","import { sign as sign_, Signature as Signature_ } from '@noble/secp256k1'\n\nimport type { Hex, Signature } from '../../types'\nimport { toHex } from '../../utils'\n\nexport type SignParameters = {\n hash: Hex\n privateKey: Hex\n}\nexport type SignReturnType = Signature\n\n/**\n * @description Signs a hash with a given private key.\n *\n * @param hash The hash to sign.\n * @param privateKey The private key to sign with.\n *\n * @returns The signature.\n */\nexport async function sign({\n hash,\n privateKey,\n}: SignParameters): Promise<SignReturnType> {\n const [sigBytes, recId] = await sign_(hash.slice(2), privateKey.slice(2), {\n canonical: true,\n recovered: true,\n })\n const sig = Signature_.fromHex(sigBytes)\n return {\n r: toHex(sig.r),\n s: toHex(sig.s),\n v: recId ? 28n : 27n,\n }\n}\n","import { Signature as Signature_ } from '@noble/secp256k1'\n\nimport type { Hex, Signature } from '../../types'\nimport { hexToBigInt, toHex } from '../../utils'\n\nexport function signatureToHex({ r, s, v }: Signature): Hex {\n return `0x${new Signature_(\n hexToBigInt(r),\n hexToBigInt(s),\n ).toCompactHex()}${toHex(v).slice(2)}`\n}\n","import type { Hex } from '../../types'\nimport { hashMessage } from '../../utils'\nimport { sign } from './sign'\nimport { signatureToHex } from './signatureToHex'\n\nexport type SignMessageParameters = {\n /** The message to sign. */\n message: string\n /** The private key to sign with. */\n privateKey: Hex\n}\nexport type SignMessageReturnType = Hex\n\n/**\n * @description Calculates an Ethereum-specific signature in [EIP-191 format](https://eips.ethereum.org/EIPS/eip-191):\n * `keccak256(\"\\x19Ethereum Signed Message:\\n\" + len(message) + message))`.\n *\n * @returns The signature.\n */\nexport async function signMessage({\n message,\n privateKey,\n}: SignMessageParameters): Promise<SignMessageReturnType> {\n const signature = await sign({ hash: hashMessage(message), privateKey })\n return signatureToHex(signature)\n}\n","import type {\n Hex,\n TransactionSerializable,\n TransactionSerialized,\n TransactionType,\n} from '../../types'\nimport {\n GetTransactionType,\n keccak256,\n serializeTransaction,\n} from '../../utils'\nimport { sign } from './sign'\n\nexport type SignTransactionArgs<\n TTransactionSerializable extends TransactionSerializable = TransactionSerializable,\n> = {\n privateKey: Hex\n transaction: TTransactionSerializable\n}\nexport type SignTransactionReturnType<\n TTransactionSerializable extends TransactionSerializable = TransactionSerializable,\n TTransactionType extends TransactionType = GetTransactionType<TTransactionSerializable>,\n> = TransactionSerialized<TTransactionType>\n\nexport async function signTransaction<\n TTransactionSerializable extends TransactionSerializable,\n>({\n privateKey,\n transaction,\n}: SignTransactionArgs<TTransactionSerializable>): Promise<\n SignTransactionReturnType<TTransactionSerializable>\n> {\n const signature = await sign({\n hash: keccak256(serializeTransaction(transaction)),\n privateKey,\n })\n return serializeTransaction(transaction, signature)\n}\n","import type { TypedData } from 'abitype'\n\nimport type { Hex, TypedDataDefinition } from '../../types'\nimport { HashTypedDataParameters, hashTypedData } from '../../utils'\nimport { sign } from './sign'\nimport { signatureToHex } from './signatureToHex'\n\nexport type SignTypedDataParameters<\n TTypedData extends TypedData | { [key: string]: unknown } = TypedData,\n TPrimaryType extends string = string,\n> = TypedDataDefinition<TTypedData, TPrimaryType> & {\n /** The private key to sign with. */\n privateKey: Hex\n}\n\nexport type SignTypedDataReturnType = Hex\n\n/**\n * @description Signs typed data and calculates an Ethereum-specific signature in [EIP-191 format](https://eips.ethereum.org/EIPS/eip-191):\n * `keccak256(\"\\x19Ethereum Signed Message:\\n\" + len(message) + message))`.\n *\n * @returns The signature.\n */\nexport async function signTypedData<\n TTypedData extends TypedData | { [key: string]: unknown },\n TPrimaryType extends string = string,\n>({\n privateKey,\n ...typedData\n}: SignTypedDataParameters<\n TTypedData,\n TPrimaryType\n>): Promise<SignTypedDataReturnType> {\n const signature = await sign({\n hash: hashTypedData(typedData as HashTypedDataParameters),\n privateKey,\n })\n return signatureToHex(signature)\n}\n","export { wordlist as czech } from '@scure/bip39/wordlists/czech'\nexport { wordlist as english } from '@scure/bip39/wordlists/english'\nexport { wordlist as french } from '@scure/bip39/wordlists/french'\nexport { wordlist as italian } from '@scure/bip39/wordlists/italian'\nexport { wordlist as japanese } from '@scure/bip39/wordlists/japanese'\nexport { wordlist as korean } from '@scure/bip39/wordlists/korean'\nexport { wordlist as simplifiedChinese } from '@scure/bip39/wordlists/simplified-chinese'\nexport { wordlist as spanish } from '@scure/bip39/wordlists/spanish'\nexport { wordlist as traditionalChinese } from '@scure/bip39/wordlists/traditional-chinese'\n"],"mappings":"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","names":["wordlist","Signature_","Signature_","wordlist"]}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { ab as Formatters, C as Chain } from './chain-4af995bf.js';
|
2
2
|
|
3
3
|
declare function defineChain<TFormatters extends Formatters = Formatters, TChain extends Chain<TFormatters> = Chain<TFormatters>>(chain: TChain): TChain;
|
4
4
|
declare function getChainContractAddress({ blockNumber, chain, contract: name, }: {
|