viem 0.2.0-jxom-local-accounts.20230321T210352 → 0.2.0-jxom-local-accounts.20230321T212822
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/accounts/package.json +4 -0
- package/dist/abi.js +2 -2
- package/dist/abi.mjs +1 -1
- package/dist/accounts/index.d.ts +33 -0
- package/dist/accounts/index.js +89 -0
- package/dist/accounts/index.js.map +1 -0
- package/dist/accounts/index.mjs +89 -0
- package/dist/accounts/index.mjs.map +1 -0
- package/dist/chains.js +63 -63
- package/dist/chains.mjs +1 -1
- package/dist/{chunk-IXGTN6B7.mjs → chunk-6UKHPIXX.mjs} +2 -2
- package/dist/chunk-FNVFGFWN.mjs +31 -0
- package/dist/chunk-FNVFGFWN.mjs.map +1 -0
- package/dist/chunk-FQM5MF6U.js +31 -0
- package/dist/chunk-FQM5MF6U.js.map +1 -0
- package/dist/{chunk-PB263D6W.mjs → chunk-IVRML3IK.mjs} +869 -880
- package/dist/chunk-IVRML3IK.mjs.map +1 -0
- package/dist/{chunk-K66BKQUH.js → chunk-LYQKHD7R.js} +19 -19
- package/dist/{chunk-FHJTO6BQ.js → chunk-NJSAEA2H.js} +821 -832
- package/dist/chunk-NJSAEA2H.js.map +1 -0
- package/dist/contract.d.ts +3 -2
- package/dist/contract.js +2 -2
- package/dist/contract.mjs +1 -1
- package/dist/{createPublicClient-62c74ebc.d.ts → createPublicClient-d2c37c92.d.ts} +2 -2
- package/dist/ens.d.ts +3 -2
- package/dist/ens.js +3 -3
- package/dist/ens.mjs +2 -2
- package/dist/ethers.d.ts +2 -1
- package/dist/ethers.js +5 -3
- package/dist/ethers.js.map +1 -1
- package/dist/ethers.mjs +4 -2
- package/dist/ethers.mjs.map +1 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.js +91 -91
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/dist/parseAccount-2d7ea01d.d.ts +6 -0
- package/dist/{parseGwei-7efc43fc.d.ts → parseGwei-377678bc.d.ts} +7 -7
- package/dist/public.d.ts +3 -2
- package/dist/public.js +2 -2
- package/dist/public.mjs +1 -1
- package/dist/test.js +2 -2
- package/dist/test.mjs +1 -1
- package/dist/{typedData-0514bb3c.d.ts → typedData-ade018d6.d.ts} +19 -2
- package/dist/utils/index.d.ts +7 -5
- package/dist/utils/index.js +4 -2
- package/dist/utils/index.mjs +3 -1
- package/dist/wallet.d.ts +3 -2
- package/dist/wallet.js +2 -2
- package/dist/wallet.mjs +1 -1
- package/package.json +7 -1
- package/dist/chunk-FHJTO6BQ.js.map +0 -1
- package/dist/chunk-PB263D6W.mjs.map +0 -1
- /package/dist/{chunk-IXGTN6B7.mjs.map → chunk-6UKHPIXX.mjs.map} +0 -0
- /package/dist/{chunk-K66BKQUH.js.map → chunk-LYQKHD7R.js.map} +0 -0
package/dist/abi.js
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
|
8
8
|
|
9
9
|
|
10
|
-
var
|
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 =
|
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
@@ -0,0 +1,33 @@
|
|
1
|
+
export { HDKey } from '@scure/bip32';
|
2
|
+
import { P as PrivateKeyAccount, a as AccountSource, J as JsonRpcAccount, C as CustomSource, L as LocalAccount, T as TypedDataDefinition } from '../typedData-ade018d6.js';
|
3
|
+
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-ade018d6.js';
|
4
|
+
import { H as Hex } from '../chain-75b0942e.js';
|
5
|
+
import { Address, TypedData } from 'abitype';
|
6
|
+
export { p as parseAccount } from '../parseAccount-2d7ea01d.js';
|
7
|
+
import '@wagmi/chains';
|
8
|
+
|
9
|
+
declare function privateKeyToAccount(privateKey: Hex): PrivateKeyAccount;
|
10
|
+
|
11
|
+
type GetAccountReturnType<TAccountSource extends AccountSource> = (TAccountSource extends Address ? JsonRpcAccount : never) | (TAccountSource extends CustomSource ? LocalAccount : never);
|
12
|
+
declare function toAccount<TAccountSource extends AccountSource>(source: TAccountSource): GetAccountReturnType<TAccountSource>;
|
13
|
+
|
14
|
+
declare function publicKeyToAddress(publicKey: Hex): Address;
|
15
|
+
|
16
|
+
type SignMessageParameters = {
|
17
|
+
message: string;
|
18
|
+
privateKey: Hex;
|
19
|
+
};
|
20
|
+
type SignMessageReturnType = Hex;
|
21
|
+
declare function signMessage({ message, privateKey, }: SignMessageParameters): Promise<SignMessageReturnType>;
|
22
|
+
|
23
|
+
type SignTypedDataParameters<TTypedData extends TypedData | {
|
24
|
+
[key: string]: unknown;
|
25
|
+
} = TypedData, TPrimaryType extends string = string> = TypedDataDefinition<TTypedData, TPrimaryType> & {
|
26
|
+
privateKey: Hex;
|
27
|
+
};
|
28
|
+
type SignTypedDataReturnType = Hex;
|
29
|
+
declare function signTypedData<TTypedData extends TypedData | {
|
30
|
+
[key: string]: unknown;
|
31
|
+
}, TPrimaryType extends string = string>({ privateKey, ...typedData }: SignTypedDataParameters<TTypedData, TPrimaryType>): Promise<SignTypedDataReturnType>;
|
32
|
+
|
33
|
+
export { SignMessageParameters, SignMessageReturnType, SignTypedDataParameters, SignTypedDataReturnType, privateKeyToAccount, publicKeyToAddress, signMessage, signTypedData, toAccount };
|
@@ -0,0 +1,89 @@
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
2
|
+
|
3
|
+
var _chunkFQM5MF6Ujs = require('../chunk-FQM5MF6U.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/privateKeyToAccount.ts
|
17
|
+
var _secp256k1 = require('@noble/secp256k1');
|
18
|
+
|
19
|
+
// src/accounts/utils/publicKeyToAddress.ts
|
20
|
+
function publicKeyToAddress(publicKey) {
|
21
|
+
const address = _chunkNJSAEA2Hjs.keccak256.call(void 0, `0x${publicKey.substring(4)}`).substring(26);
|
22
|
+
return _chunkNJSAEA2Hjs.checksumAddress.call(void 0, `0x${address}`);
|
23
|
+
}
|
24
|
+
|
25
|
+
// src/accounts/utils/sign.ts
|
26
|
+
|
27
|
+
async function sign({
|
28
|
+
hash,
|
29
|
+
privateKey
|
30
|
+
}) {
|
31
|
+
const [signature, recId] = await _secp256k1.sign.call(void 0, hash.slice(2), privateKey.slice(2), {
|
32
|
+
canonical: true,
|
33
|
+
recovered: true
|
34
|
+
});
|
35
|
+
return `0x${_secp256k1.Signature.fromHex(signature).toCompactHex()}${recId ? "1c" : "1b"}`;
|
36
|
+
}
|
37
|
+
|
38
|
+
// src/accounts/utils/signMessage.ts
|
39
|
+
async function signMessage({
|
40
|
+
message,
|
41
|
+
privateKey
|
42
|
+
}) {
|
43
|
+
return sign({ hash: _chunkNJSAEA2Hjs.hashMessage.call(void 0, message), privateKey });
|
44
|
+
}
|
45
|
+
|
46
|
+
// src/accounts/utils/signTypedData.ts
|
47
|
+
async function signTypedData({
|
48
|
+
privateKey,
|
49
|
+
...typedData
|
50
|
+
}) {
|
51
|
+
return sign({
|
52
|
+
hash: _chunkNJSAEA2Hjs.hashTypedData.call(void 0, typedData),
|
53
|
+
privateKey
|
54
|
+
});
|
55
|
+
}
|
56
|
+
|
57
|
+
// src/accounts/privateKeyToAccount.ts
|
58
|
+
function privateKeyToAccount(privateKey) {
|
59
|
+
const publicKey = _chunkNJSAEA2Hjs.toHex.call(void 0, _secp256k1.getPublicKey.call(void 0, privateKey.slice(2)));
|
60
|
+
const address = publicKeyToAddress(publicKey);
|
61
|
+
const account = _chunkFQM5MF6Ujs.toAccount.call(void 0, {
|
62
|
+
address,
|
63
|
+
async signMessage({ message }) {
|
64
|
+
return signMessage({ message, privateKey });
|
65
|
+
},
|
66
|
+
async signTransaction(_transaction) {
|
67
|
+
return "0x";
|
68
|
+
},
|
69
|
+
async signTypedData(typedData) {
|
70
|
+
return signTypedData({ ...typedData, privateKey });
|
71
|
+
}
|
72
|
+
});
|
73
|
+
return {
|
74
|
+
...account,
|
75
|
+
getPrivateKey: () => privateKey,
|
76
|
+
publicKey,
|
77
|
+
source: "privateKey"
|
78
|
+
};
|
79
|
+
}
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
exports.HDKey = _bip32.HDKey; exports.parseAccount = _chunkNJSAEA2Hjs.parseAccount; exports.privateKeyToAccount = privateKeyToAccount; exports.publicKeyToAddress = publicKeyToAddress; exports.signMessage = signMessage; exports.signTypedData = signTypedData; exports.toAccount = _chunkFQM5MF6Ujs.toAccount;
|
89
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../src/accounts/index.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"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,SAAS,aAAa;;;ACAtB,SAAS,oBAAoB;;;ACItB,SAAS,mBAAmB,WAAyB;AAC1D,QAAM,UAAU,UAAU,KAAK,UAAU,UAAU,CAAC,GAAG,EAAE,UAAU,EAAE;AACrE,SAAO,gBAAgB,KAAK,SAAS;AACvC;;;ACPA,SAAS,QAAQ,OAAO,iBAAiB;AAUzC,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;;;ACAA,eAAsB,cAGpB;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAGqC;AACnC,SAAO,KAAK;AAAA,IACV,MAAM,cAAc,SAAoC;AAAA,IACxD;AAAA,EACF,CAAC;AACH;;;AJrBO,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","sourcesContent":["import { HDKey } from '@scure/bip32'\n\nexport { HDKey }\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","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\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\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\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 message: string\n privateKey: Hex\n}\nexport type SignMessageReturnType = Hex\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 privateKey: Hex\n}\n\nexport type SignTypedDataReturnType = Hex\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"]}
|
@@ -0,0 +1,89 @@
|
|
1
|
+
import {
|
2
|
+
toAccount
|
3
|
+
} from "../chunk-FNVFGFWN.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/privateKeyToAccount.ts
|
17
|
+
import { getPublicKey } from "@noble/secp256k1";
|
18
|
+
|
19
|
+
// src/accounts/utils/publicKeyToAddress.ts
|
20
|
+
function publicKeyToAddress(publicKey) {
|
21
|
+
const address = keccak256(`0x${publicKey.substring(4)}`).substring(26);
|
22
|
+
return checksumAddress(`0x${address}`);
|
23
|
+
}
|
24
|
+
|
25
|
+
// src/accounts/utils/sign.ts
|
26
|
+
import { sign as sign_, Signature } from "@noble/secp256k1";
|
27
|
+
async function sign({
|
28
|
+
hash,
|
29
|
+
privateKey
|
30
|
+
}) {
|
31
|
+
const [signature, recId] = await sign_(hash.slice(2), privateKey.slice(2), {
|
32
|
+
canonical: true,
|
33
|
+
recovered: true
|
34
|
+
});
|
35
|
+
return `0x${Signature.fromHex(signature).toCompactHex()}${recId ? "1c" : "1b"}`;
|
36
|
+
}
|
37
|
+
|
38
|
+
// src/accounts/utils/signMessage.ts
|
39
|
+
async function signMessage({
|
40
|
+
message,
|
41
|
+
privateKey
|
42
|
+
}) {
|
43
|
+
return sign({ hash: hashMessage(message), privateKey });
|
44
|
+
}
|
45
|
+
|
46
|
+
// src/accounts/utils/signTypedData.ts
|
47
|
+
async function signTypedData({
|
48
|
+
privateKey,
|
49
|
+
...typedData
|
50
|
+
}) {
|
51
|
+
return sign({
|
52
|
+
hash: hashTypedData(typedData),
|
53
|
+
privateKey
|
54
|
+
});
|
55
|
+
}
|
56
|
+
|
57
|
+
// src/accounts/privateKeyToAccount.ts
|
58
|
+
function privateKeyToAccount(privateKey) {
|
59
|
+
const publicKey = toHex(getPublicKey(privateKey.slice(2)));
|
60
|
+
const address = publicKeyToAddress(publicKey);
|
61
|
+
const account = toAccount({
|
62
|
+
address,
|
63
|
+
async signMessage({ message }) {
|
64
|
+
return signMessage({ message, privateKey });
|
65
|
+
},
|
66
|
+
async signTransaction(_transaction) {
|
67
|
+
return "0x";
|
68
|
+
},
|
69
|
+
async signTypedData(typedData) {
|
70
|
+
return signTypedData({ ...typedData, privateKey });
|
71
|
+
}
|
72
|
+
});
|
73
|
+
return {
|
74
|
+
...account,
|
75
|
+
getPrivateKey: () => privateKey,
|
76
|
+
publicKey,
|
77
|
+
source: "privateKey"
|
78
|
+
};
|
79
|
+
}
|
80
|
+
export {
|
81
|
+
HDKey,
|
82
|
+
parseAccount,
|
83
|
+
privateKeyToAccount,
|
84
|
+
publicKeyToAddress,
|
85
|
+
signMessage,
|
86
|
+
signTypedData,
|
87
|
+
toAccount
|
88
|
+
};
|
89
|
+
//# sourceMappingURL=index.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../src/accounts/index.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"],"sourcesContent":["import { HDKey } from '@scure/bip32'\n\nexport { HDKey }\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","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\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\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\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 message: string\n privateKey: Hex\n}\nexport type SignMessageReturnType = Hex\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 privateKey: Hex\n}\n\nexport type SignTypedDataReturnType = Hex\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"],"mappings":";;;;;;;;;;;;;AAAA,SAAS,aAAa;;;ACAtB,SAAS,oBAAoB;;;ACItB,SAAS,mBAAmB,WAAyB;AAC1D,QAAM,UAAU,UAAU,KAAK,UAAU,UAAU,CAAC,GAAG,EAAE,UAAU,EAAE;AACrE,SAAO,gBAAgB,KAAK,SAAS;AACvC;;;ACPA,SAAS,QAAQ,OAAO,iBAAiB;AAUzC,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;;;ACAA,eAAsB,cAGpB;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAGqC;AACnC,SAAO,KAAK;AAAA,IACV,MAAM,cAAc,SAAoC;AAAA,IACxD;AAAA,EACF,CAAC;AACH;;;AJrBO,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;","names":[]}
|
package/dist/chains.js
CHANGED
@@ -4,32 +4,32 @@
|
|
4
4
|
|
5
5
|
|
6
6
|
|
7
|
-
var
|
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:
|
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:
|
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:
|
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:
|
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 =
|
41
|
-
var arbitrumGoerli2 =
|
42
|
-
var aurora2 =
|
43
|
-
var auroraGoerli =
|
44
|
-
var avalanche2 =
|
45
|
-
var avalancheFuji2 =
|
46
|
-
var baseGoerli2 =
|
47
|
-
var boba2 =
|
48
|
-
var bronos2 =
|
49
|
-
var bronosTestnet2 =
|
50
|
-
var bsc2 =
|
51
|
-
var bscTestnet2 =
|
52
|
-
var canto2 =
|
53
|
-
var celo2 =
|
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 =
|
57
|
+
var celoAlfajores2 = _chunkNJSAEA2Hjs.defineChain.call(void 0, {
|
58
58
|
...chains.celoAlfajores,
|
59
59
|
formatters: celoFormatters
|
60
60
|
});
|
61
|
-
var crossbell2 =
|
62
|
-
var evmos2 =
|
63
|
-
var evmosTestnet2 =
|
64
|
-
var fantom2 =
|
65
|
-
var fantomTestnet2 =
|
66
|
-
var filecoin2 =
|
67
|
-
var filecoinCalibration2 =
|
68
|
-
var filecoinHyperspace2 =
|
69
|
-
var flare2 =
|
70
|
-
var flareTestnet2 =
|
71
|
-
var foundry2 =
|
72
|
-
var goerli2 =
|
73
|
-
var gnosis2 =
|
74
|
-
var gnosisChiado2 =
|
75
|
-
var hardhat2 =
|
76
|
-
var harmonyOne2 =
|
77
|
-
var iotex2 =
|
78
|
-
var iotexTestnet2 =
|
79
|
-
var localhost2 =
|
80
|
-
var mainnet2 =
|
81
|
-
var metis2 =
|
82
|
-
var metisGoerli2 =
|
83
|
-
var moonbaseAlpha2 =
|
84
|
-
var moonbeam2 =
|
85
|
-
var moonriver2 =
|
86
|
-
var okc2 =
|
87
|
-
var optimism2 =
|
88
|
-
var optimismGoerli2 =
|
89
|
-
var polygon2 =
|
90
|
-
var polygonMumbai2 =
|
91
|
-
var polygonZkEvmTestnet2 =
|
92
|
-
var sepolia2 =
|
93
|
-
var shardeumSphinx2 =
|
94
|
-
var songbird2 =
|
95
|
-
var songbirdTestnet2 =
|
96
|
-
var taraxa2 =
|
97
|
-
var taraxaTestnet2 =
|
98
|
-
var telos2 =
|
99
|
-
var telosTestnet2 =
|
100
|
-
var zhejiang2 =
|
101
|
-
var zkSync2 =
|
102
|
-
var zkSyncTestnet2 =
|
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 =
|
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
@@ -11,7 +11,7 @@ import {
|
|
11
11
|
stringToBytes,
|
12
12
|
toBytes,
|
13
13
|
toHex
|
14
|
-
} from "./chunk-
|
14
|
+
} from "./chunk-IVRML3IK.mjs";
|
15
15
|
|
16
16
|
// src/utils/ens/labelhash.ts
|
17
17
|
function labelhash(label) {
|
@@ -183,4 +183,4 @@ export {
|
|
183
183
|
getEnsAddress,
|
184
184
|
getEnsName
|
185
185
|
};
|
186
|
-
//# sourceMappingURL=chunk-
|
186
|
+
//# sourceMappingURL=chunk-6UKHPIXX.mjs.map
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import {
|
2
|
+
InvalidAddressError,
|
3
|
+
isAddress
|
4
|
+
} from "./chunk-IVRML3IK.mjs";
|
5
|
+
|
6
|
+
// src/accounts/toAccount.ts
|
7
|
+
function toAccount(source) {
|
8
|
+
if (typeof source === "string") {
|
9
|
+
if (!isAddress(source))
|
10
|
+
throw new InvalidAddressError({ address: source });
|
11
|
+
return {
|
12
|
+
address: source,
|
13
|
+
type: "json-rpc"
|
14
|
+
};
|
15
|
+
}
|
16
|
+
if (!isAddress(source.address))
|
17
|
+
throw new 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
|
+
export {
|
29
|
+
toAccount
|
30
|
+
};
|
31
|
+
//# sourceMappingURL=chunk-FNVFGFWN.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/accounts/toAccount.ts"],"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\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"],"mappings":";;;;;;AAcO,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;","names":[]}
|
@@ -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-FQM5MF6U.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/accounts/toAccount.ts"],"names":[],"mappings":";;;;;;AAcO,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\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"]}
|