viem 0.2.0-jxom-local-accounts.20230325T211645 → 0.2.0-jxom-local-accounts.20230327T004031
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +4 -4
- package/dist/accounts/index.js +45 -16
- package/dist/accounts/index.js.map +1 -1
- package/dist/accounts/index.mjs +39 -10
- package/dist/accounts/index.mjs.map +1 -1
- package/dist/{chain-f8db473f.d.ts → chain-40443542.d.ts} +1 -1
- package/dist/{chain-75b0942e.d.ts → chain-4af995bf.d.ts} +63 -27
- package/dist/chains.d.ts +3 -3
- package/dist/chains.js +63 -63
- package/dist/chains.mjs +1 -1
- package/dist/{chunk-NJSAEA2H.js → chunk-CGTZNR2R.js} +507 -3
- package/dist/chunk-CGTZNR2R.js.map +1 -0
- package/dist/{chunk-IVRML3IK.mjs → chunk-HWVZ6VEQ.mjs} +506 -2
- package/dist/chunk-HWVZ6VEQ.mjs.map +1 -0
- package/dist/{chunk-ZHKTGT4Q.mjs → chunk-PVK5TA2L.mjs} +2 -2
- package/dist/{chunk-6UKHPIXX.mjs → chunk-UCNDS4FE.mjs} +2 -2
- package/dist/chunk-UCNDS4FE.mjs.map +1 -0
- package/dist/{chunk-LYQKHD7R.js → chunk-VSAG2LPH.js} +19 -19
- package/dist/chunk-VSAG2LPH.js.map +1 -0
- package/dist/{chunk-35AQXWIB.js → chunk-XLIQDCZW.js} +6 -6
- package/dist/contract.d.ts +8 -8
- package/dist/contract.js +2 -2
- package/dist/contract.mjs +1 -1
- package/dist/{createClient-f87255c1.d.ts → createClient-1f19be8d.d.ts} +23 -9
- package/dist/{createPublicClient-f876dff3.d.ts → createPublicClient-b53e3c3d.d.ts} +116 -116
- package/dist/{eip1193-ae706fd8.d.ts → eip1193-210ab776.d.ts} +1 -1
- package/dist/{encodeFunctionResult-4792a6a3.d.ts → encodeFunctionResult-a252fba1.d.ts} +1 -1
- package/dist/{encodePacked-3fcdd54b.d.ts → encodePacked-a9464e97.d.ts} +1 -1
- package/dist/ens.d.ts +5 -5
- package/dist/ens.js +3 -3
- package/dist/ens.mjs +2 -2
- package/dist/ethers.d.ts +3 -3
- package/dist/ethers.js +4 -4
- package/dist/ethers.mjs +2 -2
- package/dist/{formatAbiItem-765ebc53.d.ts → formatAbiItem-6ed70dbd.d.ts} +1 -1
- package/dist/{getAbiItem-693e6e1b.d.ts → getAbiItem-1ff0f41a.d.ts} +1 -1
- package/dist/index.d.ts +21 -15
- package/dist/index.js +127 -102
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +67 -42
- package/dist/index.mjs.map +1 -1
- package/dist/{parseAccount-b6e8bc40.d.ts → parseAccount-8e131c73.d.ts} +1 -1
- package/dist/{parseGwei-1030ed5a.d.ts → parseGwei-b3a175f7.d.ts} +51 -7
- package/dist/public.d.ts +5 -5
- 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-7cfe4bb6.d.ts → typedData-848139b1.d.ts} +7 -11
- package/dist/utils/index.d.ts +16 -36
- package/dist/utils/index.js +18 -2
- package/dist/utils/index.mjs +17 -1
- package/dist/wallet.d.ts +5 -5
- package/dist/wallet.js +2 -2
- package/dist/wallet.mjs +1 -1
- package/dist/window.d.ts +2 -2
- package/package.json +1 -1
- package/dist/chunk-6UKHPIXX.mjs.map +0 -1
- package/dist/chunk-IVRML3IK.mjs.map +0 -1
- package/dist/chunk-LYQKHD7R.js.map +0 -1
- package/dist/chunk-NJSAEA2H.js.map +0 -1
- package/dist/test-98c0b642.d.ts +0 -206
- /package/dist/{chunk-ZHKTGT4Q.mjs.map → chunk-PVK5TA2L.mjs.map} +0 -0
- /package/dist/{chunk-35AQXWIB.js.map → chunk-XLIQDCZW.js.map} +0 -0
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 _chunkCGTZNR2Rjs = require('./chunk-CGTZNR2R.js');
|
11
11
|
|
12
12
|
|
13
13
|
|
@@ -17,5 +17,5 @@ var _chunkNJSAEA2Hjs = require('./chunk-NJSAEA2H.js');
|
|
17
17
|
|
18
18
|
|
19
19
|
|
20
|
-
exports.decodeAbiParameters =
|
20
|
+
exports.decodeAbiParameters = _chunkCGTZNR2Rjs.decodeAbiParameters; exports.encodeAbiParameters = _chunkCGTZNR2Rjs.encodeAbiParameters; exports.encodePacked = _chunkCGTZNR2Rjs.encodePacked; exports.getAbiItem = _chunkCGTZNR2Rjs.getAbiItem; exports.parseAbi = _chunkCGTZNR2Rjs.parseAbi; exports.parseAbiItem = _chunkCGTZNR2Rjs.parseAbiItem; exports.parseAbiParameter = _chunkCGTZNR2Rjs.parseAbiParameter; exports.parseAbiParameters = _chunkCGTZNR2Rjs.parseAbiParameters;
|
21
21
|
//# sourceMappingURL=abi.js.map
|
package/dist/abi.mjs
CHANGED
package/dist/accounts/index.d.ts
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
export { HDKey } from '@scure/bip32';
|
2
|
-
import { H as Hex } from '../chain-
|
3
|
-
import { P as PrivateKeyAccount, a as AccountSource, J as JsonRpcAccount, C as CustomSource, L as LocalAccount, T as TypedDataDefinition } from '../typedData-
|
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-
|
2
|
+
import { H as Hex } from '../chain-4af995bf.js';
|
3
|
+
import { P as PrivateKeyAccount, a as AccountSource, J as JsonRpcAccount, C as CustomSource, L as LocalAccount, T as TypedDataDefinition } from '../typedData-848139b1.js';
|
4
|
+
export { A as Account, a as AccountSource, C as CustomSource, H as HDAccount, b as HDOptions, J as JsonRpcAccount, L as LocalAccount, P as PrivateKeyAccount } from '../typedData-848139b1.js';
|
5
5
|
import { Address, TypedData } from 'abitype';
|
6
|
-
export { p as parseAccount } from '../parseAccount-
|
6
|
+
export { p as parseAccount } from '../parseAccount-8e131c73.js';
|
7
7
|
export { wordlist as czech } from '@scure/bip39/wordlists/czech';
|
8
8
|
export { wordlist as english } from '@scure/bip39/wordlists/english';
|
9
9
|
export { wordlist as french } from '@scure/bip39/wordlists/french';
|
package/dist/accounts/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
2
2
|
|
3
|
-
var
|
3
|
+
var _chunkXLIQDCZWjs = require('../chunk-XLIQDCZW.js');
|
4
4
|
|
5
5
|
|
6
6
|
|
@@ -8,7 +8,9 @@ var _chunk35AQXWIBjs = require('../chunk-35AQXWIB.js');
|
|
8
8
|
|
9
9
|
|
10
10
|
|
11
|
-
|
11
|
+
|
12
|
+
|
13
|
+
var _chunkCGTZNR2Rjs = require('../chunk-CGTZNR2R.js');
|
12
14
|
|
13
15
|
// src/accounts/index.ts
|
14
16
|
var _bip32 = require('@scure/bip32');
|
@@ -22,7 +24,7 @@ function generateMnemonic(wordlist10) {
|
|
22
24
|
// src/accounts/generatePrivateKey.ts
|
23
25
|
var _secp256k1 = require('@noble/secp256k1');
|
24
26
|
function generatePrivateKey() {
|
25
|
-
return
|
27
|
+
return _chunkCGTZNR2Rjs.toHex.call(void 0, _secp256k1.utils.randomPrivateKey());
|
26
28
|
}
|
27
29
|
|
28
30
|
// src/accounts/privateKeyToAccount.ts
|
@@ -30,8 +32,8 @@ function generatePrivateKey() {
|
|
30
32
|
|
31
33
|
// src/accounts/utils/publicKeyToAddress.ts
|
32
34
|
function publicKeyToAddress(publicKey) {
|
33
|
-
const address =
|
34
|
-
return
|
35
|
+
const address = _chunkCGTZNR2Rjs.keccak256.call(void 0, `0x${publicKey.substring(4)}`).substring(26);
|
36
|
+
return _chunkCGTZNR2Rjs.checksumAddress.call(void 0, `0x${address}`);
|
35
37
|
}
|
36
38
|
|
37
39
|
// src/accounts/utils/sign.ts
|
@@ -40,11 +42,25 @@ async function sign({
|
|
40
42
|
hash,
|
41
43
|
privateKey
|
42
44
|
}) {
|
43
|
-
const [
|
45
|
+
const [sigBytes, recId] = await _secp256k1.sign.call(void 0, hash.slice(2), privateKey.slice(2), {
|
44
46
|
canonical: true,
|
45
47
|
recovered: true
|
46
48
|
});
|
47
|
-
|
49
|
+
const sig = _secp256k1.Signature.fromHex(sigBytes);
|
50
|
+
return {
|
51
|
+
r: _chunkCGTZNR2Rjs.toHex.call(void 0, sig.r),
|
52
|
+
s: _chunkCGTZNR2Rjs.toHex.call(void 0, sig.s),
|
53
|
+
v: recId ? 28n : 27n
|
54
|
+
};
|
55
|
+
}
|
56
|
+
|
57
|
+
// src/accounts/utils/signatureToHex.ts
|
58
|
+
|
59
|
+
function signatureToHex({ r, s, v }) {
|
60
|
+
return `0x${new (0, _secp256k1.Signature)(
|
61
|
+
_chunkCGTZNR2Rjs.hexToBigInt.call(void 0, r),
|
62
|
+
_chunkCGTZNR2Rjs.hexToBigInt.call(void 0, s)
|
63
|
+
).toCompactHex()}${_chunkCGTZNR2Rjs.toHex.call(void 0, v).slice(2)}`;
|
48
64
|
}
|
49
65
|
|
50
66
|
// src/accounts/utils/signMessage.ts
|
@@ -52,7 +68,20 @@ async function signMessage({
|
|
52
68
|
message,
|
53
69
|
privateKey
|
54
70
|
}) {
|
55
|
-
|
71
|
+
const signature = await sign({ hash: _chunkCGTZNR2Rjs.hashMessage.call(void 0, message), privateKey });
|
72
|
+
return signatureToHex(signature);
|
73
|
+
}
|
74
|
+
|
75
|
+
// src/accounts/utils/signTransaction.ts
|
76
|
+
async function signTransaction({
|
77
|
+
privateKey,
|
78
|
+
transaction
|
79
|
+
}) {
|
80
|
+
const signature = await sign({
|
81
|
+
hash: _chunkCGTZNR2Rjs.keccak256.call(void 0, _chunkCGTZNR2Rjs.serializeTransaction.call(void 0, transaction)),
|
82
|
+
privateKey
|
83
|
+
});
|
84
|
+
return _chunkCGTZNR2Rjs.serializeTransaction.call(void 0, transaction, signature);
|
56
85
|
}
|
57
86
|
|
58
87
|
// src/accounts/utils/signTypedData.ts
|
@@ -60,23 +89,24 @@ async function signTypedData({
|
|
60
89
|
privateKey,
|
61
90
|
...typedData
|
62
91
|
}) {
|
63
|
-
|
64
|
-
hash:
|
92
|
+
const signature = await sign({
|
93
|
+
hash: _chunkCGTZNR2Rjs.hashTypedData.call(void 0, typedData),
|
65
94
|
privateKey
|
66
95
|
});
|
96
|
+
return signatureToHex(signature);
|
67
97
|
}
|
68
98
|
|
69
99
|
// src/accounts/privateKeyToAccount.ts
|
70
100
|
function privateKeyToAccount(privateKey) {
|
71
|
-
const publicKey =
|
101
|
+
const publicKey = _chunkCGTZNR2Rjs.toHex.call(void 0, _secp256k1.getPublicKey.call(void 0, privateKey.slice(2)));
|
72
102
|
const address = publicKeyToAddress(publicKey);
|
73
|
-
const account =
|
103
|
+
const account = _chunkXLIQDCZWjs.toAccount.call(void 0, {
|
74
104
|
address,
|
75
105
|
async signMessage({ message }) {
|
76
106
|
return signMessage({ message, privateKey });
|
77
107
|
},
|
78
|
-
async signTransaction(
|
79
|
-
return
|
108
|
+
async signTransaction(transaction) {
|
109
|
+
return signTransaction({ privateKey, transaction });
|
80
110
|
},
|
81
111
|
async signTypedData(typedData) {
|
82
112
|
return signTypedData({ ...typedData, privateKey });
|
@@ -84,7 +114,6 @@ function privateKeyToAccount(privateKey) {
|
|
84
114
|
});
|
85
115
|
return {
|
86
116
|
...account,
|
87
|
-
getPrivateKey: () => privateKey,
|
88
117
|
publicKey,
|
89
118
|
source: "privateKey"
|
90
119
|
};
|
@@ -119,5 +148,5 @@ var _traditionalchinese = require('@scure/bip39/wordlists/traditional-chinese');
|
|
119
148
|
|
120
149
|
|
121
150
|
|
122
|
-
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 =
|
151
|
+
exports.HDKey = _bip32.HDKey; exports.czech = _czech.wordlist; exports.english = _english.wordlist; exports.french = _french.wordlist; exports.generateMnemonic = generateMnemonic; exports.generatePrivateKey = generatePrivateKey; exports.italian = _italian.wordlist; exports.japanese = _japanese.wordlist; exports.korean = _korean.wordlist; exports.parseAccount = _chunkCGTZNR2Rjs.parseAccount; exports.privateKeyToAccount = privateKeyToAccount; exports.publicKeyToAddress = publicKeyToAddress; exports.signMessage = signMessage; exports.signTypedData = signTypedData; exports.simplifiedChinese = _simplifiedchinese.wordlist; exports.spanish = _spanish.wordlist; exports.toAccount = _chunkXLIQDCZWjs.toAccount; exports.traditionalChinese = _traditionalchinese.wordlist;
|
123
152
|
//# 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/publicKeyToAddress.ts","../../src/accounts/utils/sign.ts","../../src/accounts/utils/signMessage.ts","../../src/accounts/utils/signTypedData.ts","../../src/accounts/wordlists.ts"],"names":["wordlist"],"mappings":";;;;;;;;;;;;;AAAA,SAAS,aAAa;;;ACAtB,SAAS,oBAAoB,yBAAyB;AAS/C,SAAS,iBAAiBA,YAA4B;AAC3D,SAAO,kBAAkBA,UAAQ;AACnC;;;ACXA,SAAS,aAAa;AAUf,SAAS,qBAA0B;AACxC,SAAO,MAAM,MAAM,iBAAiB,CAAC;AACvC;;;ACZA,SAAS,oBAAoB;;;ACWtB,SAAS,mBAAmB,WAAyB;AAC1D,QAAM,UAAU,UAAU,KAAK,UAAU,UAAU,CAAC,GAAG,EAAE,UAAU,EAAE;AACrE,SAAO,gBAAgB,KAAK,SAAS;AACvC;;;ACdA,SAAS,QAAQ,OAAO,iBAAiB;AAkBzC,eAAsB,KAAK;AAAA,EACzB;AAAA,EACA;AACF,GAA4C;AAC1C,QAAM,CAAC,WAAW,KAAK,IAAI,MAAM,MAAM,KAAK,MAAM,CAAC,GAAG,WAAW,MAAM,CAAC,GAAG;AAAA,IACzE,WAAW;AAAA,IACX,WAAW;AAAA,EACb,CAAC;AACD,SAAO,KAAK,UAAU,QAAQ,SAAS,EAAE,aAAa,IACpD,QAAQ,OAAO;AAEnB;;;ACXA,eAAsB,YAAY;AAAA,EAChC;AAAA,EACA;AACF,GAA0D;AACxD,SAAO,KAAK,EAAE,MAAM,YAAY,OAAO,GAAG,WAAW,CAAC;AACxD;;;ACDA,eAAsB,cAGpB;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAGqC;AACnC,SAAO,KAAK;AAAA,IACV,MAAM,cAAc,SAAoC;AAAA,IACxD;AAAA,EACF,CAAC;AACH;;;AJvBO,SAAS,oBAAoB,YAAoC;AACtE,QAAM,YAAY,MAAM,aAAa,WAAW,MAAM,CAAC,CAAC,CAAC;AACzD,QAAM,UAAU,mBAAmB,SAAS;AAE5C,QAAM,UAAU,UAAU;AAAA,IACxB;AAAA,IACA,MAAM,YAAY,EAAE,QAAQ,GAAG;AAC7B,aAAO,YAAY,EAAE,SAAS,WAAW,CAAC;AAAA,IAC5C;AAAA,IACA,MAAM,gBAAgB,cAAc;AAElC,aAAO;AAAA,IACT;AAAA,IACA,MAAM,cAAc,WAAW;AAC7B,aAAO,cAAc,EAAE,GAAG,WAAW,WAAW,CAAC;AAAA,IACnD;AAAA,EACF,CAAC;AAED,SAAO;AAAA,IACL,GAAG;AAAA,IACH,eAAe,MAAM;AAAA,IACrB;AAAA,IACA,QAAQ;AAAA,EACV;AACF;;;AKrCA,SAAqB,gBAAa;AAClC,SAAqB,YAAZA,iBAA2B;AACpC,SAAqB,YAAZA,iBAA0B;AACnC,SAAqB,YAAZA,iBAA2B;AACpC,SAAqB,YAAZA,iBAA4B;AACrC,SAAqB,YAAZA,iBAA0B;AACnC,SAAqB,YAAZA,iBAAqC;AAC9C,SAAqB,YAAZA,iBAA2B;AACpC,SAAqB,YAAZA,iBAAsC","sourcesContent":["import { HDKey } from '@scure/bip32'\n\nexport { HDKey }\n\nexport { generateMnemonic } from './generateMnemonic'\n\nexport { generatePrivateKey } from './generatePrivateKey'\n\nexport { privateKeyToAccount } from './privateKeyToAccount'\n\nexport { toAccount } from './toAccount'\n\nexport type {\n Account,\n AccountSource,\n CustomSource,\n HDOptions,\n JsonRpcAccount,\n LocalAccount,\n HDAccount,\n PrivateKeyAccount,\n} from './types'\n\nexport type {\n SignMessageParameters,\n SignMessageReturnType,\n SignTypedDataParameters,\n SignTypedDataReturnType,\n} from './utils'\nexport {\n parseAccount,\n publicKeyToAddress,\n signMessage,\n signTypedData,\n} from './utils'\n\nexport {\n czech,\n english,\n french,\n italian,\n japanese,\n korean,\n simplifiedChinese,\n spanish,\n traditionalChinese,\n} from './wordlists'\n","import { generateMnemonic as generateMnemonic_ } from '@scure/bip39'\n\n/**\n * @description Generates a random mnemonic phrase with a given wordlist.\n *\n * @param wordlist The wordlist to use for generating the mnemonic phrase.\n *\n * @returns A randomly generated mnemonic phrase.\n */\nexport function generateMnemonic(wordlist: string[]): string {\n return generateMnemonic_(wordlist)\n}\n","import { 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 { publicKeyToAddress, signMessage, signTypedData } 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 // TODO\n return '0x'\n },\n async signTypedData(typedData) {\n return signTypedData({ ...typedData, privateKey })\n },\n })\n\n return {\n ...account,\n getPrivateKey: () => privateKey,\n publicKey,\n source: 'privateKey',\n }\n}\n","import type { Address, Hex } from '../../types'\nimport { keccak256 } from '../../utils'\nimport { checksumAddress } from '../../utils/address'\n\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 } from '@noble/secp256k1'\n\nimport type { Hex } from '../../types'\n\nexport type SignParameters = {\n hash: Hex\n privateKey: Hex\n}\nexport type SignReturnType = Hex\n\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 [signature, recId] = await sign_(hash.slice(2), privateKey.slice(2), {\n canonical: true,\n recovered: true,\n })\n return `0x${Signature.fromHex(signature).toCompactHex()}${\n recId ? '1c' : '1b'\n }`\n}\n","import type { Hex } from '../../types'\nimport { hashMessage } from '../../utils'\nimport { sign } from './sign'\n\nexport type SignMessageParameters = {\n /** 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 return sign({ hash: hashMessage(message), privateKey })\n}\n","import type { TypedData } from 'abitype'\n\nimport type { Hex, TypedDataDefinition } from '../../types'\nimport { HashTypedDataParameters, hashTypedData } from '../../utils'\nimport { sign } from './sign'\n\nexport type SignTypedDataParameters<\n TTypedData extends TypedData | { [key: string]: unknown } = TypedData,\n TPrimaryType extends string = string,\n> = TypedDataDefinition<TTypedData, TPrimaryType> & {\n /** 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 return sign({\n hash: hashTypedData(typedData as HashTypedDataParameters),\n privateKey,\n })\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/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"]}
|
package/dist/accounts/index.mjs
CHANGED
@@ -1,14 +1,16 @@
|
|
1
1
|
import {
|
2
2
|
toAccount
|
3
|
-
} from "../chunk-
|
3
|
+
} from "../chunk-PVK5TA2L.mjs";
|
4
4
|
import {
|
5
5
|
checksumAddress,
|
6
6
|
hashMessage,
|
7
7
|
hashTypedData,
|
8
|
+
hexToBigInt,
|
8
9
|
keccak256,
|
9
10
|
parseAccount,
|
11
|
+
serializeTransaction,
|
10
12
|
toHex
|
11
|
-
} from "../chunk-
|
13
|
+
} from "../chunk-HWVZ6VEQ.mjs";
|
12
14
|
|
13
15
|
// src/accounts/index.ts
|
14
16
|
import { HDKey } from "@scure/bip32";
|
@@ -35,16 +37,30 @@ function publicKeyToAddress(publicKey) {
|
|
35
37
|
}
|
36
38
|
|
37
39
|
// src/accounts/utils/sign.ts
|
38
|
-
import { sign as sign_, Signature } from "@noble/secp256k1";
|
40
|
+
import { sign as sign_, Signature as Signature_ } from "@noble/secp256k1";
|
39
41
|
async function sign({
|
40
42
|
hash,
|
41
43
|
privateKey
|
42
44
|
}) {
|
43
|
-
const [
|
45
|
+
const [sigBytes, recId] = await sign_(hash.slice(2), privateKey.slice(2), {
|
44
46
|
canonical: true,
|
45
47
|
recovered: true
|
46
48
|
});
|
47
|
-
|
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)}`;
|
48
64
|
}
|
49
65
|
|
50
66
|
// src/accounts/utils/signMessage.ts
|
@@ -52,7 +68,20 @@ async function signMessage({
|
|
52
68
|
message,
|
53
69
|
privateKey
|
54
70
|
}) {
|
55
|
-
|
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);
|
56
85
|
}
|
57
86
|
|
58
87
|
// src/accounts/utils/signTypedData.ts
|
@@ -60,10 +89,11 @@ async function signTypedData({
|
|
60
89
|
privateKey,
|
61
90
|
...typedData
|
62
91
|
}) {
|
63
|
-
|
92
|
+
const signature = await sign({
|
64
93
|
hash: hashTypedData(typedData),
|
65
94
|
privateKey
|
66
95
|
});
|
96
|
+
return signatureToHex(signature);
|
67
97
|
}
|
68
98
|
|
69
99
|
// src/accounts/privateKeyToAccount.ts
|
@@ -75,8 +105,8 @@ function privateKeyToAccount(privateKey) {
|
|
75
105
|
async signMessage({ message }) {
|
76
106
|
return signMessage({ message, privateKey });
|
77
107
|
},
|
78
|
-
async signTransaction(
|
79
|
-
return
|
108
|
+
async signTransaction(transaction) {
|
109
|
+
return signTransaction({ privateKey, transaction });
|
80
110
|
},
|
81
111
|
async signTypedData(typedData) {
|
82
112
|
return signTypedData({ ...typedData, privateKey });
|
@@ -84,7 +114,6 @@ function privateKeyToAccount(privateKey) {
|
|
84
114
|
});
|
85
115
|
return {
|
86
116
|
...account,
|
87
|
-
getPrivateKey: () => privateKey,
|
88
117
|
publicKey,
|
89
118
|
source: "privateKey"
|
90
119
|
};
|
@@ -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/publicKeyToAddress.ts","../../src/accounts/utils/sign.ts","../../src/accounts/utils/signMessage.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 { publicKeyToAddress, signMessage, signTypedData } 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 // TODO\n return '0x'\n },\n async signTypedData(typedData) {\n return signTypedData({ ...typedData, privateKey })\n },\n })\n\n return {\n ...account,\n getPrivateKey: () => privateKey,\n publicKey,\n source: 'privateKey',\n }\n}\n","import type { Address, Hex } from '../../types'\nimport { keccak256 } from '../../utils'\nimport { checksumAddress } from '../../utils/address'\n\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 } from '@noble/secp256k1'\n\nimport type { Hex } from '../../types'\n\nexport type SignParameters = {\n hash: Hex\n privateKey: Hex\n}\nexport type SignReturnType = Hex\n\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 [signature, recId] = await sign_(hash.slice(2), privateKey.slice(2), {\n canonical: true,\n recovered: true,\n })\n return `0x${Signature.fromHex(signature).toCompactHex()}${\n recId ? '1c' : '1b'\n }`\n}\n","import type { Hex } from '../../types'\nimport { hashMessage } from '../../utils'\nimport { sign } from './sign'\n\nexport type SignMessageParameters = {\n /** 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 return sign({ hash: hashMessage(message), privateKey })\n}\n","import type { TypedData } from 'abitype'\n\nimport type { Hex, TypedDataDefinition } from '../../types'\nimport { HashTypedDataParameters, hashTypedData } from '../../utils'\nimport { sign } from './sign'\n\nexport type SignTypedDataParameters<\n TTypedData extends TypedData | { [key: string]: unknown } = TypedData,\n TPrimaryType extends string = string,\n> = TypedDataDefinition<TTypedData, TPrimaryType> & {\n /** 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 return sign({\n hash: hashTypedData(typedData as HashTypedDataParameters),\n privateKey,\n })\n}\n","export { wordlist as czech } from '@scure/bip39/wordlists/czech'\nexport { wordlist as english } from '@scure/bip39/wordlists/english'\nexport { wordlist as french } from '@scure/bip39/wordlists/french'\nexport { wordlist as italian } from '@scure/bip39/wordlists/italian'\nexport { wordlist as japanese } from '@scure/bip39/wordlists/japanese'\nexport { wordlist as korean } from '@scure/bip39/wordlists/korean'\nexport { wordlist as simplifiedChinese } from '@scure/bip39/wordlists/simplified-chinese'\nexport { wordlist as spanish } from '@scure/bip39/wordlists/spanish'\nexport { wordlist as traditionalChinese } from '@scure/bip39/wordlists/traditional-chinese'\n"],"mappings":";;;;;;;;;;;;;AAAA,SAAS,aAAa;;;ACAtB,SAAS,oBAAoB,yBAAyB;AAS/C,SAAS,iBAAiBA,YAA4B;AAC3D,SAAO,kBAAkBA,UAAQ;AACnC;;;ACXA,SAAS,aAAa;AAUf,SAAS,qBAA0B;AACxC,SAAO,MAAM,MAAM,iBAAiB,CAAC;AACvC;;;ACZA,SAAS,oBAAoB;;;ACWtB,SAAS,mBAAmB,WAAyB;AAC1D,QAAM,UAAU,UAAU,KAAK,UAAU,UAAU,CAAC,GAAG,EAAE,UAAU,EAAE;AACrE,SAAO,gBAAgB,KAAK,SAAS;AACvC;;;ACdA,SAAS,QAAQ,OAAO,iBAAiB;AAkBzC,eAAsB,KAAK;AAAA,EACzB;AAAA,EACA;AACF,GAA4C;AAC1C,QAAM,CAAC,WAAW,KAAK,IAAI,MAAM,MAAM,KAAK,MAAM,CAAC,GAAG,WAAW,MAAM,CAAC,GAAG;AAAA,IACzE,WAAW;AAAA,IACX,WAAW;AAAA,EACb,CAAC;AACD,SAAO,KAAK,UAAU,QAAQ,SAAS,EAAE,aAAa,IACpD,QAAQ,OAAO;AAEnB;;;ACXA,eAAsB,YAAY;AAAA,EAChC;AAAA,EACA;AACF,GAA0D;AACxD,SAAO,KAAK,EAAE,MAAM,YAAY,OAAO,GAAG,WAAW,CAAC;AACxD;;;ACDA,eAAsB,cAGpB;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAGqC;AACnC,SAAO,KAAK;AAAA,IACV,MAAM,cAAc,SAAoC;AAAA,IACxD;AAAA,EACF,CAAC;AACH;;;AJvBO,SAAS,oBAAoB,YAAoC;AACtE,QAAM,YAAY,MAAM,aAAa,WAAW,MAAM,CAAC,CAAC,CAAC;AACzD,QAAM,UAAU,mBAAmB,SAAS;AAE5C,QAAM,UAAU,UAAU;AAAA,IACxB;AAAA,IACA,MAAM,YAAY,EAAE,QAAQ,GAAG;AAC7B,aAAO,YAAY,EAAE,SAAS,WAAW,CAAC;AAAA,IAC5C;AAAA,IACA,MAAM,gBAAgB,cAAc;AAElC,aAAO;AAAA,IACT;AAAA,IACA,MAAM,cAAc,WAAW;AAC7B,aAAO,cAAc,EAAE,GAAG,WAAW,WAAW,CAAC;AAAA,IACnD;AAAA,EACF,CAAC;AAED,SAAO;AAAA,IACL,GAAG;AAAA,IACH,eAAe,MAAM;AAAA,IACrB;AAAA,IACA,QAAQ;AAAA,EACV;AACF;;;AKrCA,SAAqB,gBAAa;AAClC,SAAqB,YAAZC,iBAA2B;AACpC,SAAqB,YAAZA,iBAA0B;AACnC,SAAqB,YAAZA,iBAA2B;AACpC,SAAqB,YAAZA,iBAA4B;AACrC,SAAqB,YAAZA,iBAA0B;AACnC,SAAqB,YAAZA,iBAAqC;AAC9C,SAAqB,YAAZA,iBAA2B;AACpC,SAAqB,YAAZA,iBAAsC;","names":["wordlist","wordlist"]}
|
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":";;;;;;;;;;;;;;;AAAA,SAAS,aAAa;;;ACAtB,SAAS,oBAAoB,yBAAyB;AAS/C,SAAS,iBAAiBA,YAA4B;AAC3D,SAAO,kBAAkBA,UAAQ;AACnC;;;ACXA,SAAS,aAAa;AAUf,SAAS,qBAA0B;AACxC,SAAO,MAAM,MAAM,iBAAiB,CAAC;AACvC;;;ACZA,SAAS,oBAAoB;;;ACWtB,SAAS,mBAAmB,WAAyB;AAC1D,QAAM,UAAU,UAAU,KAAK,UAAU,UAAU,CAAC,GAAG,EAAE,UAAU,EAAE;AACrE,SAAO,gBAAgB,KAAK,SAAS;AACvC;;;ACdA,SAAS,QAAQ,OAAO,aAAa,kBAAkB;AAmBvD,eAAsB,KAAK;AAAA,EACzB;AAAA,EACA;AACF,GAA4C;AAC1C,QAAM,CAAC,UAAU,KAAK,IAAI,MAAM,MAAM,KAAK,MAAM,CAAC,GAAG,WAAW,MAAM,CAAC,GAAG;AAAA,IACxE,WAAW;AAAA,IACX,WAAW;AAAA,EACb,CAAC;AACD,QAAM,MAAM,WAAW,QAAQ,QAAQ;AACvC,SAAO;AAAA,IACL,GAAG,MAAM,IAAI,CAAC;AAAA,IACd,GAAG,MAAM,IAAI,CAAC;AAAA,IACd,GAAG,QAAQ,MAAM;AAAA,EACnB;AACF;;;ACjCA,SAAS,aAAaC,mBAAkB;AAKjC,SAAS,eAAe,EAAE,GAAG,GAAG,EAAE,GAAmB;AAC1D,SAAO,KAAK,IAAIC;AAAA,IACd,YAAY,CAAC;AAAA,IACb,YAAY,CAAC;AAAA,EACf,EAAE,aAAa,IAAI,MAAM,CAAC,EAAE,MAAM,CAAC;AACrC;;;ACSA,eAAsB,YAAY;AAAA,EAChC;AAAA,EACA;AACF,GAA0D;AACxD,QAAM,YAAY,MAAM,KAAK,EAAE,MAAM,YAAY,OAAO,GAAG,WAAW,CAAC;AACvE,SAAO,eAAe,SAAS;AACjC;;;ACDA,eAAsB,gBAEpB;AAAA,EACA;AAAA,EACA;AACF,GAEE;AACA,QAAM,YAAY,MAAM,KAAK;AAAA,IAC3B,MAAM,UAAU,qBAAqB,WAAW,CAAC;AAAA,IACjD;AAAA,EACF,CAAC;AACD,SAAO,qBAAqB,aAAa,SAAS;AACpD;;;ACdA,eAAsB,cAGpB;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAGqC;AACnC,QAAM,YAAY,MAAM,KAAK;AAAA,IAC3B,MAAM,cAAc,SAAoC;AAAA,IACxD;AAAA,EACF,CAAC;AACD,SAAO,eAAe,SAAS;AACjC;;;ANpBO,SAAS,oBAAoB,YAAoC;AACtE,QAAM,YAAY,MAAM,aAAa,WAAW,MAAM,CAAC,CAAC,CAAC;AACzD,QAAM,UAAU,mBAAmB,SAAS;AAE5C,QAAM,UAAU,UAAU;AAAA,IACxB;AAAA,IACA,MAAM,YAAY,EAAE,QAAQ,GAAG;AAC7B,aAAO,YAAY,EAAE,SAAS,WAAW,CAAC;AAAA,IAC5C;AAAA,IACA,MAAM,gBAAgB,aAAa;AACjC,aAAO,gBAAgB,EAAE,YAAY,YAAY,CAAC;AAAA,IACpD;AAAA,IACA,MAAM,cAAc,WAAW;AAC7B,aAAO,cAAc,EAAE,GAAG,WAAW,WAAW,CAAC;AAAA,IACnD;AAAA,EACF,CAAC;AAED,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,IACA,QAAQ;AAAA,EACV;AACF;;;AOxCA,SAAqB,gBAAa;AAClC,SAAqB,YAAZC,iBAA2B;AACpC,SAAqB,YAAZA,iBAA0B;AACnC,SAAqB,YAAZA,iBAA2B;AACpC,SAAqB,YAAZA,iBAA4B;AACrC,SAAqB,YAAZA,iBAA0B;AACnC,SAAqB,YAAZA,iBAAqC;AAC9C,SAAqB,YAAZA,iBAA2B;AACpC,SAAqB,YAAZA,iBAAsC;","names":["wordlist","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, }: {
|
@@ -1,11 +1,6 @@
|
|
1
1
|
import { Chain as Chain$1 } from '@wagmi/chains';
|
2
2
|
import { Abi, AbiFunction, ExtractAbiFunction, AbiParametersToPrimitiveTypes, AbiConstructor, AbiError, ExtractAbiError, AbiEvent, ExtractAbiEvent, ExtractAbiErrorNames, ExtractAbiEventNames, AbiStateMutability, ExtractAbiFunctionNames, Narrow, Address, AbiParameter, AbiParameterToPrimitiveType } from 'abitype';
|
3
3
|
|
4
|
-
type ByteArray = Uint8Array;
|
5
|
-
type Hex = `0x${string}`;
|
6
|
-
type Hash = `0x${string}`;
|
7
|
-
type LogTopic = Hex | Hex[] | null;
|
8
|
-
|
9
4
|
type ExtractFormatter<TChain extends Chain, TKey extends keyof NonNullable<TChain['formatters']>, TFallbackFormatter extends Formatter = Formatter> = NonNullable<TChain['formatters']>[TKey] extends NonNullable<unknown> ? NonNullable<TChain['formatters']>[TKey] : TFallbackFormatter;
|
10
5
|
type FormatOptions<TSource, TTarget> = {
|
11
6
|
formatter: Formatter<TSource, TTarget>;
|
@@ -51,13 +46,23 @@ declare const transactionType: {
|
|
51
46
|
declare function formatTransaction(transaction: Partial<RpcTransaction>): Transaction<bigint, number>;
|
52
47
|
declare const defineTransaction: <TFormat extends Formatter<Partial<RpcTransaction>, Partial<Transaction<bigint, number>> & {
|
53
48
|
[key: string]: unknown;
|
54
|
-
}>, TExclude extends ("type" | "value" | "blockHash" | "blockNumber" | "from" | "gasPrice" | "maxFeePerGas" | "maxPriorityFeePerGas" | "gas" | "nonce" | "to" | "accessList" | "
|
49
|
+
}>, TExclude extends ("type" | "value" | "blockHash" | "blockNumber" | "chainId" | "from" | "gasPrice" | "maxFeePerGas" | "maxPriorityFeePerGas" | "gas" | "nonce" | "to" | "accessList" | "r" | "s" | "v" | "transactionIndex" | "hash" | "input")[] = []>({ exclude, format: formatOverride, }: {
|
55
50
|
exclude?: TExclude | undefined;
|
56
51
|
format?: TFormat | undefined;
|
57
52
|
}) => (data: Partial<RpcTransaction> & {
|
58
53
|
[key: string]: unknown;
|
59
54
|
}) => Transaction<bigint, number> & ReturnType<TFormat> & { [K in TExclude[number]]: never; };
|
60
55
|
|
56
|
+
type ByteArray = Uint8Array;
|
57
|
+
type Hex = `0x${string}`;
|
58
|
+
type Hash = `0x${string}`;
|
59
|
+
type LogTopic = Hex | Hex[] | null;
|
60
|
+
type Signature = {
|
61
|
+
r: Hex;
|
62
|
+
s: Hex;
|
63
|
+
v: bigint;
|
64
|
+
};
|
65
|
+
|
61
66
|
type FeeHistory<TQuantity = bigint> = {
|
62
67
|
/**
|
63
68
|
* An array of block base fees per gas (in wei). This includes the next block after
|
@@ -86,6 +91,14 @@ type FeeValuesEIP1559<TQuantity = bigint> = {
|
|
86
91
|
};
|
87
92
|
type FeeValues<TQuantity = bigint> = FeeValuesLegacy<TQuantity> | FeeValuesEIP1559<TQuantity>;
|
88
93
|
|
94
|
+
/**
|
95
|
+
* @description Checks if {@link T} is `undefined`
|
96
|
+
* @param T - Type to check
|
97
|
+
* @example
|
98
|
+
* type Result = IsUndefined<undefined>
|
99
|
+
* // ^? true
|
100
|
+
*/
|
101
|
+
type IsUndefined<T> = [undefined] extends [T] ? true : false;
|
89
102
|
/**
|
90
103
|
* @description Excludes empty attributes from T if TMaybeExclude is true.
|
91
104
|
*
|
@@ -335,27 +348,12 @@ type Log<TQuantity = bigint, TIndex = number, TAbiEvent extends AbiEvent | undef
|
|
335
348
|
removed: boolean;
|
336
349
|
} & DecodedAbiEvent<TAbiEvent, TAbi, TEventName>;
|
337
350
|
|
338
|
-
type Index = `0x${string}`;
|
339
|
-
type Quantity = `0x${string}`;
|
340
|
-
type Status = '0x0' | '0x1';
|
341
|
-
type TransactionType$1 = '0x0' | '0x1' | '0x2';
|
342
|
-
type RpcBlock = Block<Quantity, RpcTransaction>;
|
343
|
-
type RpcBlockNumber = BlockNumber<Quantity>;
|
344
|
-
type RpcBlockIdentifier = BlockIdentifier<Quantity>;
|
345
|
-
type RpcUncle = Uncle<Quantity>;
|
346
|
-
type RpcFeeHistory = FeeHistory<Quantity>;
|
347
|
-
type RpcFeeValues = FeeValues<Quantity>;
|
348
|
-
type RpcLog = Log<Quantity, Index>;
|
349
|
-
type RpcTransactionReceipt = TransactionReceipt<Quantity, Index, Status, TransactionType$1>;
|
350
|
-
type RpcTransactionRequest = TransactionRequest<Quantity, Index>;
|
351
|
-
type RpcTransaction = TransactionLegacy<Quantity, Index, '0x0'> | TransactionEIP2930<Quantity, Index, '0x1'> | TransactionEIP1559<Quantity, Index, '0x2'>;
|
352
|
-
|
353
351
|
type AccessList = {
|
354
352
|
address: Address;
|
355
353
|
storageKeys: Hex[];
|
356
354
|
}[];
|
357
|
-
type TransactionType = ValueOf<typeof transactionType>;
|
358
|
-
type TransactionReceipt<TQuantity = bigint, TIndex = number, TStatus = 'success' | 'reverted', TType = TransactionType> = {
|
355
|
+
type TransactionType$1 = ValueOf<typeof transactionType>;
|
356
|
+
type TransactionReceipt<TQuantity = bigint, TIndex = number, TStatus = 'success' | 'reverted', TType = TransactionType$1> = {
|
359
357
|
/** Hash of block containing this transaction */
|
360
358
|
blockHash: Hash;
|
361
359
|
/** Number of block containing this transaction */
|
@@ -452,6 +450,29 @@ type TransactionRequestEIP1559<TQuantity = bigint, TIndex = number> = Transactio
|
|
452
450
|
accessList?: AccessList;
|
453
451
|
};
|
454
452
|
type TransactionRequest<TQuantity = bigint, TIndex = number> = TransactionRequestLegacy<TQuantity, TIndex> | TransactionRequestEIP2930<TQuantity, TIndex> | TransactionRequestEIP1559<TQuantity, TIndex>;
|
453
|
+
type TransactionSerializedEIP1559 = `0x02${string}`;
|
454
|
+
type TransactionSerializedEIP2930 = `0x01${string}`;
|
455
|
+
type TransactionSerializedLegacy = Hex;
|
456
|
+
type TransactionSerialized<TType extends TransactionType$1 = 'legacy'> = (TType extends 'eip1559' ? TransactionSerializedEIP1559 : never) | (TType extends 'eip2930' ? TransactionSerializedEIP2930 : never) | (TType extends 'legacy' ? TransactionSerializedLegacy : never);
|
457
|
+
type TransactionSerializableBase<TQuantity = bigint, TIndex = number> = Omit<TransactionRequestBase<TQuantity, TIndex>, 'from'> & Partial<Signature>;
|
458
|
+
type TransactionSerializableLegacy<TQuantity = bigint, TIndex = number> = TransactionSerializableBase<TQuantity, TIndex> & Partial<FeeValuesLegacy<TQuantity>> & {
|
459
|
+
accessList?: never;
|
460
|
+
chainId?: number;
|
461
|
+
type?: 'legacy';
|
462
|
+
};
|
463
|
+
type TransactionSerializableEIP2930<TQuantity = bigint, TIndex = number> = TransactionSerializableBase<TQuantity, TIndex> & Partial<FeeValuesLegacy<TQuantity>> & {
|
464
|
+
accessList?: AccessList;
|
465
|
+
chainId: number;
|
466
|
+
type?: 'eip2930';
|
467
|
+
yParity?: number;
|
468
|
+
};
|
469
|
+
type TransactionSerializableEIP1559<TQuantity = bigint, TIndex = number> = TransactionSerializableBase<TQuantity, TIndex> & Partial<FeeValuesEIP1559<TQuantity>> & {
|
470
|
+
accessList?: AccessList;
|
471
|
+
chainId: number;
|
472
|
+
type?: 'eip1559';
|
473
|
+
yParity?: number;
|
474
|
+
};
|
475
|
+
type TransactionSerializable<TQuantity = bigint, TIndex = number> = TransactionSerializableLegacy<TQuantity, TIndex> | TransactionSerializableEIP2930<TQuantity, TIndex> | TransactionSerializableEIP1559<TQuantity, TIndex>;
|
455
476
|
|
456
477
|
type Block<TQuantity = bigint, TTransaction = Transaction> = {
|
457
478
|
/** Base fee per gas */
|
@@ -512,6 +533,21 @@ type BlockNumber<TQuantity = bigint> = TQuantity;
|
|
512
533
|
type BlockTag = 'latest' | 'earliest' | 'pending' | 'safe' | 'finalized';
|
513
534
|
type Uncle<TQuantity = bigint, TTransaction = Transaction> = Block<TQuantity, TTransaction>;
|
514
535
|
|
536
|
+
type Index = `0x${string}`;
|
537
|
+
type Quantity = `0x${string}`;
|
538
|
+
type Status = '0x0' | '0x1';
|
539
|
+
type TransactionType = '0x0' | '0x1' | '0x2';
|
540
|
+
type RpcBlock = Block<Quantity, RpcTransaction>;
|
541
|
+
type RpcBlockNumber = BlockNumber<Quantity>;
|
542
|
+
type RpcBlockIdentifier = BlockIdentifier<Quantity>;
|
543
|
+
type RpcUncle = Uncle<Quantity>;
|
544
|
+
type RpcFeeHistory = FeeHistory<Quantity>;
|
545
|
+
type RpcFeeValues = FeeValues<Quantity>;
|
546
|
+
type RpcLog = Log<Quantity, Index>;
|
547
|
+
type RpcTransactionReceipt = TransactionReceipt<Quantity, Index, Status, TransactionType>;
|
548
|
+
type RpcTransactionRequest = TransactionRequest<Quantity, Index>;
|
549
|
+
type RpcTransaction = TransactionLegacy<Quantity, Index, '0x0'> | TransactionEIP2930<Quantity, Index, '0x1'> | TransactionEIP1559<Quantity, Index, '0x2'>;
|
550
|
+
|
515
551
|
type Formatter<TSource = any, TTarget = any> = (value: TSource & {
|
516
552
|
[key: string]: unknown;
|
517
553
|
}) => TTarget;
|
@@ -525,10 +561,10 @@ type Formatters = {
|
|
525
561
|
type Chain<TFormatters extends Formatters = Formatters> = Chain$1 & {
|
526
562
|
formatters?: TFormatters;
|
527
563
|
};
|
528
|
-
type GetChain<TChain extends Chain | undefined, TChainOverride extends Chain | undefined =
|
529
|
-
chain?: TChainOverride | null;
|
530
|
-
} : {
|
564
|
+
type GetChain<TChain extends Chain | undefined, TChainOverride extends Chain | undefined = undefined> = IsUndefined<TChain> extends true ? {
|
531
565
|
chain: TChainOverride | null;
|
566
|
+
} : {
|
567
|
+
chain?: TChainOverride | null;
|
532
568
|
};
|
533
569
|
|
534
|
-
export {
|
570
|
+
export { TransactionSerialized as $, AbiItem as A, ByteArray as B, Chain as C, RpcTransactionRequest as D, ExtractArgsFromAbi as E, FeeHistory as F, RpcUncle as G, Hex as H, TransactionType$1 as I, TransactionBase as J, TransactionEIP1559 as K, Log as L, TransactionEIP2930 as M, TransactionLegacy as N, TransactionReceipt as O, TransactionRequest as P, TransactionRequestBase as Q, RpcBlock as R, TransactionRequestEIP1559 as S, Transaction as T, TransactionRequestEIP2930 as U, TransactionRequestLegacy as V, TransactionSerializable as W, TransactionSerializableBase as X, TransactionSerializableEIP1559 as Y, TransactionSerializableEIP2930 as Z, TransactionSerializableLegacy as _, Hash as a, TransactionSerializedEIP1559 as a0, TransactionSerializedEIP2930 as a1, TransactionSerializedLegacy as a2, Uncle as a3, ExtractFormatter as a4, Formatted as a5, FormattedTransaction as a6, TransactionFormatter as a7, defineTransaction as a8, formatTransaction as a9, transactionType as aa, Formatters as ab, Formatter as ac, MergeIntersectionProperties as ad, GetChain as ae, GetValue as af, MaybeAbiEventName as ag, MaybeExtractEventArgsFromAbi as ah, IsUndefined as ai, Prettify as aj, Quantity as ak, EventDefinition as al, Signature as am, LogTopic as an, defineFormatter as ao, format as ap, AccessList as b, Block as c, BlockIdentifier as d, BlockNumber as e, BlockTag as f, ContractConfig as g, ExtractConstructorArgsFromAbi as h, ExtractErrorArgsFromAbi as i, ExtractErrorNameFromAbi as j, ExtractEventArgsFromAbi as k, ExtractEventArgsFromTopics as l, ExtractEventNameFromAbi as m, ExtractFunctionNameFromAbi as n, ExtractNameFromAbi as o, ExtractResultFromAbi as p, FeeValues as q, FeeValuesEIP1559 as r, FeeValuesLegacy as s, RpcBlockIdentifier as t, RpcBlockNumber as u, RpcFeeHistory as v, RpcFeeValues as w, RpcLog as x, RpcTransaction as y, RpcTransactionReceipt as z };
|
package/dist/chains.d.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
export { d as defineChain } from './chain-40443542.js';
|
2
|
+
import { R as RpcBlock, c as Block, T as Transaction, H as Hex, y as RpcTransaction, z as RpcTransactionReceipt, O as TransactionReceipt, I as TransactionType, P as TransactionRequest, D as RpcTransactionRequest } from './chain-4af995bf.js';
|
3
|
+
export { C as Chain } from './chain-4af995bf.js';
|
3
4
|
import * as chains from '@wagmi/chains';
|
4
|
-
export { d as defineChain } from './chain-f8db473f.js';
|
5
5
|
import 'abitype';
|
6
6
|
|
7
7
|
declare const arbitrum: {
|