viem 0.2.0-jxom-local-accounts.20230321T210352 → 0.2.0-jxom-local-accounts.20230325T211645

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.
Files changed (56) hide show
  1. package/accounts/package.json +4 -0
  2. package/dist/abi.js +2 -2
  3. package/dist/abi.mjs +1 -1
  4. package/dist/accounts/index.d.ts +90 -0
  5. package/dist/accounts/index.js +123 -0
  6. package/dist/accounts/index.js.map +1 -0
  7. package/dist/accounts/index.mjs +123 -0
  8. package/dist/accounts/index.mjs.map +1 -0
  9. package/dist/chains.js +63 -63
  10. package/dist/chains.mjs +1 -1
  11. package/dist/chunk-35AQXWIB.js +31 -0
  12. package/dist/chunk-35AQXWIB.js.map +1 -0
  13. package/dist/{chunk-IXGTN6B7.mjs → chunk-6UKHPIXX.mjs} +2 -2
  14. package/dist/{chunk-PB263D6W.mjs → chunk-IVRML3IK.mjs} +869 -880
  15. package/dist/chunk-IVRML3IK.mjs.map +1 -0
  16. package/dist/{chunk-K66BKQUH.js → chunk-LYQKHD7R.js} +19 -19
  17. package/dist/{chunk-FHJTO6BQ.js → chunk-NJSAEA2H.js} +821 -832
  18. package/dist/chunk-NJSAEA2H.js.map +1 -0
  19. package/dist/chunk-ZHKTGT4Q.mjs +31 -0
  20. package/dist/chunk-ZHKTGT4Q.mjs.map +1 -0
  21. package/dist/contract.d.ts +3 -2
  22. package/dist/contract.js +2 -2
  23. package/dist/contract.mjs +1 -1
  24. package/dist/{createPublicClient-62c74ebc.d.ts → createPublicClient-f876dff3.d.ts} +2 -2
  25. package/dist/ens.d.ts +3 -2
  26. package/dist/ens.js +3 -3
  27. package/dist/ens.mjs +2 -2
  28. package/dist/ethers.d.ts +2 -1
  29. package/dist/ethers.js +5 -3
  30. package/dist/ethers.js.map +1 -1
  31. package/dist/ethers.mjs +4 -2
  32. package/dist/ethers.mjs.map +1 -1
  33. package/dist/index.d.ts +5 -4
  34. package/dist/index.js +91 -91
  35. package/dist/index.js.map +1 -1
  36. package/dist/index.mjs +2 -2
  37. package/dist/index.mjs.map +1 -1
  38. package/dist/parseAccount-b6e8bc40.d.ts +6 -0
  39. package/dist/{parseGwei-7efc43fc.d.ts → parseGwei-1030ed5a.d.ts} +7 -7
  40. package/dist/public.d.ts +3 -2
  41. package/dist/public.js +2 -2
  42. package/dist/public.mjs +1 -1
  43. package/dist/test.js +2 -2
  44. package/dist/test.mjs +1 -1
  45. package/dist/{typedData-0514bb3c.d.ts → typedData-7cfe4bb6.d.ts} +23 -2
  46. package/dist/utils/index.d.ts +7 -5
  47. package/dist/utils/index.js +4 -2
  48. package/dist/utils/index.mjs +3 -1
  49. package/dist/wallet.d.ts +3 -2
  50. package/dist/wallet.js +2 -2
  51. package/dist/wallet.mjs +1 -1
  52. package/package.json +7 -1
  53. package/dist/chunk-FHJTO6BQ.js.map +0 -1
  54. package/dist/chunk-PB263D6W.mjs.map +0 -1
  55. /package/dist/{chunk-IXGTN6B7.mjs.map → chunk-6UKHPIXX.mjs.map} +0 -0
  56. /package/dist/{chunk-K66BKQUH.js.map → chunk-LYQKHD7R.js.map} +0 -0
@@ -0,0 +1,4 @@
1
+ {
2
+ "module": "../dist/accounts/index.mjs",
3
+ "main": "../dist/accounts/index.js"
4
+ }
package/dist/abi.js CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
 
9
9
 
10
- var _chunkFHJTO6BQjs = require('./chunk-FHJTO6BQ.js');
10
+ var _chunkNJSAEA2Hjs = require('./chunk-NJSAEA2H.js');
11
11
 
12
12
 
13
13
 
@@ -17,5 +17,5 @@ var _chunkFHJTO6BQjs = require('./chunk-FHJTO6BQ.js');
17
17
 
18
18
 
19
19
 
20
- exports.decodeAbiParameters = _chunkFHJTO6BQjs.decodeAbiParameters; exports.encodeAbiParameters = _chunkFHJTO6BQjs.encodeAbiParameters; exports.encodePacked = _chunkFHJTO6BQjs.encodePacked; exports.getAbiItem = _chunkFHJTO6BQjs.getAbiItem; exports.parseAbi = _chunkFHJTO6BQjs.parseAbi; exports.parseAbiItem = _chunkFHJTO6BQjs.parseAbiItem; exports.parseAbiParameter = _chunkFHJTO6BQjs.parseAbiParameter; exports.parseAbiParameters = _chunkFHJTO6BQjs.parseAbiParameters;
20
+ exports.decodeAbiParameters = _chunkNJSAEA2Hjs.decodeAbiParameters; exports.encodeAbiParameters = _chunkNJSAEA2Hjs.encodeAbiParameters; exports.encodePacked = _chunkNJSAEA2Hjs.encodePacked; exports.getAbiItem = _chunkNJSAEA2Hjs.getAbiItem; exports.parseAbi = _chunkNJSAEA2Hjs.parseAbi; exports.parseAbiItem = _chunkNJSAEA2Hjs.parseAbiItem; exports.parseAbiParameter = _chunkNJSAEA2Hjs.parseAbiParameter; exports.parseAbiParameters = _chunkNJSAEA2Hjs.parseAbiParameters;
21
21
  //# sourceMappingURL=abi.js.map
package/dist/abi.mjs CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  parseAbiItem,
8
8
  parseAbiParameter,
9
9
  parseAbiParameters
10
- } from "./chunk-PB263D6W.mjs";
10
+ } from "./chunk-IVRML3IK.mjs";
11
11
  export {
12
12
  decodeAbiParameters,
13
13
  encodeAbiParameters,
@@ -0,0 +1,90 @@
1
+ export { HDKey } from '@scure/bip32';
2
+ import { H as Hex } from '../chain-75b0942e.js';
3
+ import { P as PrivateKeyAccount, a as AccountSource, J as JsonRpcAccount, C as CustomSource, L as LocalAccount, T as TypedDataDefinition } from '../typedData-7cfe4bb6.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-7cfe4bb6.js';
5
+ import { Address, TypedData } from 'abitype';
6
+ export { p as parseAccount } from '../parseAccount-b6e8bc40.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,123 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunk35AQXWIBjs = require('../chunk-35AQXWIB.js');
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+ var _chunkNJSAEA2Hjs = require('../chunk-NJSAEA2H.js');
12
+
13
+ // src/accounts/index.ts
14
+ var _bip32 = require('@scure/bip32');
15
+
16
+ // src/accounts/generateMnemonic.ts
17
+ var _bip39 = require('@scure/bip39');
18
+ function generateMnemonic(wordlist10) {
19
+ return _bip39.generateMnemonic.call(void 0, wordlist10);
20
+ }
21
+
22
+ // src/accounts/generatePrivateKey.ts
23
+ var _secp256k1 = require('@noble/secp256k1');
24
+ function generatePrivateKey() {
25
+ return _chunkNJSAEA2Hjs.toHex.call(void 0, _secp256k1.utils.randomPrivateKey());
26
+ }
27
+
28
+ // src/accounts/privateKeyToAccount.ts
29
+
30
+
31
+ // src/accounts/utils/publicKeyToAddress.ts
32
+ function publicKeyToAddress(publicKey) {
33
+ const address = _chunkNJSAEA2Hjs.keccak256.call(void 0, `0x${publicKey.substring(4)}`).substring(26);
34
+ return _chunkNJSAEA2Hjs.checksumAddress.call(void 0, `0x${address}`);
35
+ }
36
+
37
+ // src/accounts/utils/sign.ts
38
+
39
+ async function sign({
40
+ hash,
41
+ privateKey
42
+ }) {
43
+ const [signature, recId] = await _secp256k1.sign.call(void 0, hash.slice(2), privateKey.slice(2), {
44
+ canonical: true,
45
+ recovered: true
46
+ });
47
+ return `0x${_secp256k1.Signature.fromHex(signature).toCompactHex()}${recId ? "1c" : "1b"}`;
48
+ }
49
+
50
+ // src/accounts/utils/signMessage.ts
51
+ async function signMessage({
52
+ message,
53
+ privateKey
54
+ }) {
55
+ return sign({ hash: _chunkNJSAEA2Hjs.hashMessage.call(void 0, message), privateKey });
56
+ }
57
+
58
+ // src/accounts/utils/signTypedData.ts
59
+ async function signTypedData({
60
+ privateKey,
61
+ ...typedData
62
+ }) {
63
+ return sign({
64
+ hash: _chunkNJSAEA2Hjs.hashTypedData.call(void 0, typedData),
65
+ privateKey
66
+ });
67
+ }
68
+
69
+ // src/accounts/privateKeyToAccount.ts
70
+ function privateKeyToAccount(privateKey) {
71
+ const publicKey = _chunkNJSAEA2Hjs.toHex.call(void 0, _secp256k1.getPublicKey.call(void 0, privateKey.slice(2)));
72
+ const address = publicKeyToAddress(publicKey);
73
+ const account = _chunk35AQXWIBjs.toAccount.call(void 0, {
74
+ address,
75
+ async signMessage({ message }) {
76
+ return signMessage({ message, privateKey });
77
+ },
78
+ async signTransaction(_transaction) {
79
+ return "0x";
80
+ },
81
+ async signTypedData(typedData) {
82
+ return signTypedData({ ...typedData, privateKey });
83
+ }
84
+ });
85
+ return {
86
+ ...account,
87
+ getPrivateKey: () => privateKey,
88
+ publicKey,
89
+ source: "privateKey"
90
+ };
91
+ }
92
+
93
+ // src/accounts/wordlists.ts
94
+ var _czech = require('@scure/bip39/wordlists/czech');
95
+ var _english = require('@scure/bip39/wordlists/english');
96
+ var _french = require('@scure/bip39/wordlists/french');
97
+ var _italian = require('@scure/bip39/wordlists/italian');
98
+ var _japanese = require('@scure/bip39/wordlists/japanese');
99
+ var _korean = require('@scure/bip39/wordlists/korean');
100
+ var _simplifiedchinese = require('@scure/bip39/wordlists/simplified-chinese');
101
+ var _spanish = require('@scure/bip39/wordlists/spanish');
102
+ var _traditionalchinese = require('@scure/bip39/wordlists/traditional-chinese');
103
+
104
+
105
+
106
+
107
+
108
+
109
+
110
+
111
+
112
+
113
+
114
+
115
+
116
+
117
+
118
+
119
+
120
+
121
+
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 = _chunkNJSAEA2Hjs.parseAccount; exports.privateKeyToAccount = privateKeyToAccount; exports.publicKeyToAddress = publicKeyToAddress; exports.signMessage = signMessage; exports.signTypedData = signTypedData; exports.simplifiedChinese = _simplifiedchinese.wordlist; exports.spanish = _spanish.wordlist; exports.toAccount = _chunk35AQXWIBjs.toAccount; exports.traditionalChinese = _traditionalchinese.wordlist;
123
+ //# 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/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"]}
@@ -0,0 +1,123 @@
1
+ import {
2
+ toAccount
3
+ } from "../chunk-ZHKTGT4Q.mjs";
4
+ import {
5
+ checksumAddress,
6
+ hashMessage,
7
+ hashTypedData,
8
+ keccak256,
9
+ parseAccount,
10
+ toHex
11
+ } from "../chunk-IVRML3IK.mjs";
12
+
13
+ // src/accounts/index.ts
14
+ import { HDKey } from "@scure/bip32";
15
+
16
+ // src/accounts/generateMnemonic.ts
17
+ import { generateMnemonic as generateMnemonic_ } from "@scure/bip39";
18
+ function generateMnemonic(wordlist10) {
19
+ return generateMnemonic_(wordlist10);
20
+ }
21
+
22
+ // src/accounts/generatePrivateKey.ts
23
+ import { utils } from "@noble/secp256k1";
24
+ function generatePrivateKey() {
25
+ return toHex(utils.randomPrivateKey());
26
+ }
27
+
28
+ // src/accounts/privateKeyToAccount.ts
29
+ import { getPublicKey } from "@noble/secp256k1";
30
+
31
+ // src/accounts/utils/publicKeyToAddress.ts
32
+ function publicKeyToAddress(publicKey) {
33
+ const address = keccak256(`0x${publicKey.substring(4)}`).substring(26);
34
+ return checksumAddress(`0x${address}`);
35
+ }
36
+
37
+ // src/accounts/utils/sign.ts
38
+ import { sign as sign_, Signature } from "@noble/secp256k1";
39
+ async function sign({
40
+ hash,
41
+ privateKey
42
+ }) {
43
+ const [signature, recId] = await sign_(hash.slice(2), privateKey.slice(2), {
44
+ canonical: true,
45
+ recovered: true
46
+ });
47
+ return `0x${Signature.fromHex(signature).toCompactHex()}${recId ? "1c" : "1b"}`;
48
+ }
49
+
50
+ // src/accounts/utils/signMessage.ts
51
+ async function signMessage({
52
+ message,
53
+ privateKey
54
+ }) {
55
+ return sign({ hash: hashMessage(message), privateKey });
56
+ }
57
+
58
+ // src/accounts/utils/signTypedData.ts
59
+ async function signTypedData({
60
+ privateKey,
61
+ ...typedData
62
+ }) {
63
+ return sign({
64
+ hash: hashTypedData(typedData),
65
+ privateKey
66
+ });
67
+ }
68
+
69
+ // src/accounts/privateKeyToAccount.ts
70
+ function privateKeyToAccount(privateKey) {
71
+ const publicKey = toHex(getPublicKey(privateKey.slice(2)));
72
+ const address = publicKeyToAddress(publicKey);
73
+ const account = toAccount({
74
+ address,
75
+ async signMessage({ message }) {
76
+ return signMessage({ message, privateKey });
77
+ },
78
+ async signTransaction(_transaction) {
79
+ return "0x";
80
+ },
81
+ async signTypedData(typedData) {
82
+ return signTypedData({ ...typedData, privateKey });
83
+ }
84
+ });
85
+ return {
86
+ ...account,
87
+ getPrivateKey: () => privateKey,
88
+ publicKey,
89
+ source: "privateKey"
90
+ };
91
+ }
92
+
93
+ // src/accounts/wordlists.ts
94
+ import { wordlist } from "@scure/bip39/wordlists/czech";
95
+ import { wordlist as wordlist2 } from "@scure/bip39/wordlists/english";
96
+ import { wordlist as wordlist3 } from "@scure/bip39/wordlists/french";
97
+ import { wordlist as wordlist4 } from "@scure/bip39/wordlists/italian";
98
+ import { wordlist as wordlist5 } from "@scure/bip39/wordlists/japanese";
99
+ import { wordlist as wordlist6 } from "@scure/bip39/wordlists/korean";
100
+ import { wordlist as wordlist7 } from "@scure/bip39/wordlists/simplified-chinese";
101
+ import { wordlist as wordlist8 } from "@scure/bip39/wordlists/spanish";
102
+ import { wordlist as wordlist9 } from "@scure/bip39/wordlists/traditional-chinese";
103
+ export {
104
+ HDKey,
105
+ wordlist as czech,
106
+ wordlist2 as english,
107
+ wordlist3 as french,
108
+ generateMnemonic,
109
+ generatePrivateKey,
110
+ wordlist4 as italian,
111
+ wordlist5 as japanese,
112
+ wordlist6 as korean,
113
+ parseAccount,
114
+ privateKeyToAccount,
115
+ publicKeyToAddress,
116
+ signMessage,
117
+ signTypedData,
118
+ wordlist7 as simplifiedChinese,
119
+ wordlist8 as spanish,
120
+ toAccount,
121
+ wordlist9 as traditionalChinese
122
+ };
123
+ //# 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/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"]}
package/dist/chains.js CHANGED
@@ -4,32 +4,32 @@
4
4
 
5
5
 
6
6
 
7
- var _chunkFHJTO6BQjs = require('./chunk-FHJTO6BQ.js');
7
+ var _chunkNJSAEA2Hjs = require('./chunk-NJSAEA2H.js');
8
8
 
9
9
  // src/chains.ts
10
10
  var _chains = require('@wagmi/chains'); var chains = _interopRequireWildcard(_chains);
11
11
  var celoFormatters = {
12
- block: _chunkFHJTO6BQjs.defineBlock.call(void 0, {
12
+ block: _chunkNJSAEA2Hjs.defineBlock.call(void 0, {
13
13
  exclude: ["difficulty", "gasLimit", "mixHash", "nonce", "uncles"],
14
14
  format: (block) => ({
15
15
  randomness: block.randomness
16
16
  })
17
17
  }),
18
- transaction: _chunkFHJTO6BQjs.defineTransaction.call(void 0, {
18
+ transaction: _chunkNJSAEA2Hjs.defineTransaction.call(void 0, {
19
19
  format: (transaction) => ({
20
20
  feeCurrency: transaction.feeCurrency,
21
21
  gatewayFee: transaction.gatewayFee ? BigInt(transaction.gatewayFee) : null,
22
22
  gatewayFeeRecipient: transaction.gatewayFeeRecipient
23
23
  })
24
24
  }),
25
- transactionReceipt: _chunkFHJTO6BQjs.defineTransactionReceipt.call(void 0, {
25
+ transactionReceipt: _chunkNJSAEA2Hjs.defineTransactionReceipt.call(void 0, {
26
26
  format: (transaction) => ({
27
27
  feeCurrency: transaction.feeCurrency,
28
28
  gatewayFee: transaction.gatewayFee ? BigInt(transaction.gatewayFee) : null,
29
29
  gatewayFeeRecipient: transaction.gatewayFeeRecipient
30
30
  })
31
31
  }),
32
- transactionRequest: _chunkFHJTO6BQjs.defineTransactionRequest.call(void 0, {
32
+ transactionRequest: _chunkNJSAEA2Hjs.defineTransactionRequest.call(void 0, {
33
33
  format: (transactionRequest) => ({
34
34
  feeCurrency: transactionRequest.feeCurrency,
35
35
  gatewayFee: transactionRequest.gatewayFee,
@@ -37,69 +37,69 @@ var celoFormatters = {
37
37
  })
38
38
  })
39
39
  };
40
- var arbitrum2 = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.arbitrum);
41
- var arbitrumGoerli2 = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.arbitrumGoerli);
42
- var aurora2 = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.aurora);
43
- var auroraGoerli = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.auroraTestnet);
44
- var avalanche2 = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.avalanche);
45
- var avalancheFuji2 = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.avalancheFuji);
46
- var baseGoerli2 = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.baseGoerli);
47
- var boba2 = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.boba);
48
- var bronos2 = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.bronos);
49
- var bronosTestnet2 = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.bronosTestnet);
50
- var bsc2 = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.bsc);
51
- var bscTestnet2 = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.bscTestnet);
52
- var canto2 = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.canto);
53
- var celo2 = _chunkFHJTO6BQjs.defineChain.call(void 0, {
40
+ var arbitrum2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, chains.arbitrum);
41
+ var arbitrumGoerli2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, chains.arbitrumGoerli);
42
+ var aurora2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, chains.aurora);
43
+ var auroraGoerli = _chunkNJSAEA2Hjs.defineChain.call(void 0, chains.auroraTestnet);
44
+ var avalanche2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, chains.avalanche);
45
+ var avalancheFuji2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, chains.avalancheFuji);
46
+ var baseGoerli2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, chains.baseGoerli);
47
+ var boba2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, chains.boba);
48
+ var bronos2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, chains.bronos);
49
+ var bronosTestnet2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, chains.bronosTestnet);
50
+ var bsc2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, chains.bsc);
51
+ var bscTestnet2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, chains.bscTestnet);
52
+ var canto2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, chains.canto);
53
+ var celo2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, {
54
54
  ...chains.celo,
55
55
  formatters: celoFormatters
56
56
  });
57
- var celoAlfajores2 = _chunkFHJTO6BQjs.defineChain.call(void 0, {
57
+ var celoAlfajores2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, {
58
58
  ...chains.celoAlfajores,
59
59
  formatters: celoFormatters
60
60
  });
61
- var crossbell2 = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.crossbell);
62
- var evmos2 = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.evmos);
63
- var evmosTestnet2 = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.evmosTestnet);
64
- var fantom2 = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.fantom);
65
- var fantomTestnet2 = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.fantomTestnet);
66
- var filecoin2 = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.filecoin);
67
- var filecoinCalibration2 = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.filecoinCalibration);
68
- var filecoinHyperspace2 = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.filecoinHyperspace);
69
- var flare2 = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.flare);
70
- var flareTestnet2 = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.flareTestnet);
71
- var foundry2 = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.foundry);
72
- var goerli2 = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.goerli);
73
- var gnosis2 = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.gnosis);
74
- var gnosisChiado2 = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.gnosisChiado);
75
- var hardhat2 = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.hardhat);
76
- var harmonyOne2 = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.harmonyOne);
77
- var iotex2 = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.iotex);
78
- var iotexTestnet2 = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.iotexTestnet);
79
- var localhost2 = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.localhost);
80
- var mainnet2 = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.mainnet);
81
- var metis2 = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.metis);
82
- var metisGoerli2 = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.metisGoerli);
83
- var moonbaseAlpha2 = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.moonbaseAlpha);
84
- var moonbeam2 = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.moonbeam);
85
- var moonriver2 = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.moonriver);
86
- var okc2 = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.okc);
87
- var optimism2 = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.optimism);
88
- var optimismGoerli2 = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.optimismGoerli);
89
- var polygon2 = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.polygon);
90
- var polygonMumbai2 = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.polygonMumbai);
91
- var polygonZkEvmTestnet2 = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.polygonZkEvmTestnet);
92
- var sepolia2 = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.sepolia);
93
- var shardeumSphinx2 = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.shardeumSphinx);
94
- var songbird2 = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.songbird);
95
- var songbirdTestnet2 = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.songbirdTestnet);
96
- var taraxa2 = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.taraxa);
97
- var taraxaTestnet2 = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.taraxaTestnet);
98
- var telos2 = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.telos);
99
- var telosTestnet2 = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.telosTestnet);
100
- var zhejiang2 = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.zhejiang);
101
- var zkSync2 = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.zkSync);
102
- var zkSyncTestnet2 = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.zkSyncTestnet);
61
+ var crossbell2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, chains.crossbell);
62
+ var evmos2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, chains.evmos);
63
+ var evmosTestnet2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, chains.evmosTestnet);
64
+ var fantom2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, chains.fantom);
65
+ var fantomTestnet2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, chains.fantomTestnet);
66
+ var filecoin2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, chains.filecoin);
67
+ var filecoinCalibration2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, chains.filecoinCalibration);
68
+ var filecoinHyperspace2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, chains.filecoinHyperspace);
69
+ var flare2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, chains.flare);
70
+ var flareTestnet2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, chains.flareTestnet);
71
+ var foundry2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, chains.foundry);
72
+ var goerli2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, chains.goerli);
73
+ var gnosis2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, chains.gnosis);
74
+ var gnosisChiado2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, chains.gnosisChiado);
75
+ var hardhat2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, chains.hardhat);
76
+ var harmonyOne2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, chains.harmonyOne);
77
+ var iotex2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, chains.iotex);
78
+ var iotexTestnet2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, chains.iotexTestnet);
79
+ var localhost2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, chains.localhost);
80
+ var mainnet2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, chains.mainnet);
81
+ var metis2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, chains.metis);
82
+ var metisGoerli2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, chains.metisGoerli);
83
+ var moonbaseAlpha2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, chains.moonbaseAlpha);
84
+ var moonbeam2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, chains.moonbeam);
85
+ var moonriver2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, chains.moonriver);
86
+ var okc2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, chains.okc);
87
+ var optimism2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, chains.optimism);
88
+ var optimismGoerli2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, chains.optimismGoerli);
89
+ var polygon2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, chains.polygon);
90
+ var polygonMumbai2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, chains.polygonMumbai);
91
+ var polygonZkEvmTestnet2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, chains.polygonZkEvmTestnet);
92
+ var sepolia2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, chains.sepolia);
93
+ var shardeumSphinx2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, chains.shardeumSphinx);
94
+ var songbird2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, chains.songbird);
95
+ var songbirdTestnet2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, chains.songbirdTestnet);
96
+ var taraxa2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, chains.taraxa);
97
+ var taraxaTestnet2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, chains.taraxaTestnet);
98
+ var telos2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, chains.telos);
99
+ var telosTestnet2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, chains.telosTestnet);
100
+ var zhejiang2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, chains.zhejiang);
101
+ var zkSync2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, chains.zkSync);
102
+ var zkSyncTestnet2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, chains.zkSyncTestnet);
103
103
 
104
104
 
105
105
 
@@ -159,5 +159,5 @@ var zkSyncTestnet2 = _chunkFHJTO6BQjs.defineChain.call(void 0, chains.zkSyncTest
159
159
 
160
160
 
161
161
 
162
- exports.arbitrum = arbitrum2; exports.arbitrumGoerli = arbitrumGoerli2; exports.aurora = aurora2; exports.auroraGoerli = auroraGoerli; exports.avalanche = avalanche2; exports.avalancheFuji = avalancheFuji2; exports.baseGoerli = baseGoerli2; exports.boba = boba2; exports.bronos = bronos2; exports.bronosTestnet = bronosTestnet2; exports.bsc = bsc2; exports.bscTestnet = bscTestnet2; exports.canto = canto2; exports.celo = celo2; exports.celoAlfajores = celoAlfajores2; exports.crossbell = crossbell2; exports.defineChain = _chunkFHJTO6BQjs.defineChain; exports.evmos = evmos2; exports.evmosTestnet = evmosTestnet2; exports.fantom = fantom2; exports.fantomTestnet = fantomTestnet2; exports.filecoin = filecoin2; exports.filecoinCalibration = filecoinCalibration2; exports.filecoinHyperspace = filecoinHyperspace2; exports.flare = flare2; exports.flareTestnet = flareTestnet2; exports.foundry = foundry2; exports.gnosis = gnosis2; exports.gnosisChiado = gnosisChiado2; exports.goerli = goerli2; exports.hardhat = hardhat2; exports.harmonyOne = harmonyOne2; exports.iotex = iotex2; exports.iotexTestnet = iotexTestnet2; exports.localhost = localhost2; exports.mainnet = mainnet2; exports.metis = metis2; exports.metisGoerli = metisGoerli2; exports.moonbaseAlpha = moonbaseAlpha2; exports.moonbeam = moonbeam2; exports.moonriver = moonriver2; exports.okc = okc2; exports.optimism = optimism2; exports.optimismGoerli = optimismGoerli2; exports.polygon = polygon2; exports.polygonMumbai = polygonMumbai2; exports.polygonZkEvmTestnet = polygonZkEvmTestnet2; exports.sepolia = sepolia2; exports.shardeumSphinx = shardeumSphinx2; exports.songbird = songbird2; exports.songbirdTestnet = songbirdTestnet2; exports.taraxa = taraxa2; exports.taraxaTestnet = taraxaTestnet2; exports.telos = telos2; exports.telosTestnet = telosTestnet2; exports.zhejiang = zhejiang2; exports.zkSync = zkSync2; exports.zkSyncTestnet = zkSyncTestnet2;
162
+ exports.arbitrum = arbitrum2; exports.arbitrumGoerli = arbitrumGoerli2; exports.aurora = aurora2; exports.auroraGoerli = auroraGoerli; exports.avalanche = avalanche2; exports.avalancheFuji = avalancheFuji2; exports.baseGoerli = baseGoerli2; exports.boba = boba2; exports.bronos = bronos2; exports.bronosTestnet = bronosTestnet2; exports.bsc = bsc2; exports.bscTestnet = bscTestnet2; exports.canto = canto2; exports.celo = celo2; exports.celoAlfajores = celoAlfajores2; exports.crossbell = crossbell2; exports.defineChain = _chunkNJSAEA2Hjs.defineChain; exports.evmos = evmos2; exports.evmosTestnet = evmosTestnet2; exports.fantom = fantom2; exports.fantomTestnet = fantomTestnet2; exports.filecoin = filecoin2; exports.filecoinCalibration = filecoinCalibration2; exports.filecoinHyperspace = filecoinHyperspace2; exports.flare = flare2; exports.flareTestnet = flareTestnet2; exports.foundry = foundry2; exports.gnosis = gnosis2; exports.gnosisChiado = gnosisChiado2; exports.goerli = goerli2; exports.hardhat = hardhat2; exports.harmonyOne = harmonyOne2; exports.iotex = iotex2; exports.iotexTestnet = iotexTestnet2; exports.localhost = localhost2; exports.mainnet = mainnet2; exports.metis = metis2; exports.metisGoerli = metisGoerli2; exports.moonbaseAlpha = moonbaseAlpha2; exports.moonbeam = moonbeam2; exports.moonriver = moonriver2; exports.okc = okc2; exports.optimism = optimism2; exports.optimismGoerli = optimismGoerli2; exports.polygon = polygon2; exports.polygonMumbai = polygonMumbai2; exports.polygonZkEvmTestnet = polygonZkEvmTestnet2; exports.sepolia = sepolia2; exports.shardeumSphinx = shardeumSphinx2; exports.songbird = songbird2; exports.songbirdTestnet = songbirdTestnet2; exports.taraxa = taraxa2; exports.taraxaTestnet = taraxaTestnet2; exports.telos = telos2; exports.telosTestnet = telosTestnet2; exports.zhejiang = zhejiang2; exports.zkSync = zkSync2; exports.zkSyncTestnet = zkSyncTestnet2;
163
163
  //# sourceMappingURL=chains.js.map
package/dist/chains.mjs CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  defineTransaction,
5
5
  defineTransactionReceipt,
6
6
  defineTransactionRequest
7
- } from "./chunk-PB263D6W.mjs";
7
+ } from "./chunk-IVRML3IK.mjs";
8
8
 
9
9
  // src/chains.ts
10
10
  import * as chains from "@wagmi/chains";
@@ -0,0 +1,31 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+ var _chunkNJSAEA2Hjs = require('./chunk-NJSAEA2H.js');
5
+
6
+ // src/accounts/toAccount.ts
7
+ function toAccount(source) {
8
+ if (typeof source === "string") {
9
+ if (!_chunkNJSAEA2Hjs.isAddress.call(void 0, source))
10
+ throw new (0, _chunkNJSAEA2Hjs.InvalidAddressError)({ address: source });
11
+ return {
12
+ address: source,
13
+ type: "json-rpc"
14
+ };
15
+ }
16
+ if (!_chunkNJSAEA2Hjs.isAddress.call(void 0, source.address))
17
+ throw new (0, _chunkNJSAEA2Hjs.InvalidAddressError)({ address: source.address });
18
+ return {
19
+ address: source.address,
20
+ signMessage: source.signMessage,
21
+ signTransaction: source.signTransaction,
22
+ signTypedData: source.signTypedData,
23
+ source: "custom",
24
+ type: "local"
25
+ };
26
+ }
27
+
28
+
29
+
30
+ exports.toAccount = toAccount;
31
+ //# sourceMappingURL=chunk-35AQXWIB.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/accounts/toAccount.ts"],"names":[],"mappings":";;;;;;AAmBO,SAAS,UACd,QACsC;AACtC,MAAI,OAAO,WAAW,UAAU;AAC9B,QAAI,CAAC,UAAU,MAAM;AAAG,YAAM,IAAI,oBAAoB,EAAE,SAAS,OAAO,CAAC;AACzE,WAAO;AAAA,MACL,SAAS;AAAA,MACT,MAAM;AAAA,IACR;AAAA,EACF;AAEA,MAAI,CAAC,UAAU,OAAO,OAAO;AAC3B,UAAM,IAAI,oBAAoB,EAAE,SAAS,OAAO,QAAQ,CAAC;AAC3D,SAAO;AAAA,IACL,SAAS,OAAO;AAAA,IAChB,aAAa,OAAO;AAAA,IACpB,iBAAiB,OAAO;AAAA,IACxB,eAAe,OAAO;AAAA,IACtB,QAAQ;AAAA,IACR,MAAM;AAAA,EACR;AACF","sourcesContent":["import { InvalidAddressError } from '../errors'\nimport type { Address } from '../types'\nimport { isAddress } from '../utils'\nimport type {\n AccountSource,\n CustomSource,\n JsonRpcAccount,\n LocalAccount,\n} from './types'\n\ntype GetAccountReturnType<TAccountSource extends AccountSource> =\n | (TAccountSource extends Address ? JsonRpcAccount : never)\n | (TAccountSource extends CustomSource ? LocalAccount : never)\n\n/**\n * @description Creates an Account from a custom signing implementation.\n *\n * @returns A Local Account.\n */\nexport function toAccount<TAccountSource extends AccountSource>(\n source: TAccountSource,\n): GetAccountReturnType<TAccountSource> {\n if (typeof source === 'string') {\n if (!isAddress(source)) throw new InvalidAddressError({ address: source })\n return {\n address: source,\n type: 'json-rpc',\n } as GetAccountReturnType<TAccountSource>\n }\n\n if (!isAddress(source.address))\n throw new InvalidAddressError({ address: source.address })\n return {\n address: source.address,\n signMessage: source.signMessage,\n signTransaction: source.signTransaction,\n signTypedData: source.signTypedData,\n source: 'custom',\n type: 'local',\n } as GetAccountReturnType<TAccountSource>\n}\n"]}