@faremeter/wallet-evm 0.1.1 → 0.4.0

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.
@@ -1,5 +1,11 @@
1
- import { type WalletClient, type Hex } from "viem";
1
+ import { type WalletClient, type Hex, type Chain } from "viem";
2
2
  import { privateKeyToAccount } from "viem/accounts";
3
+ interface NetworkConfig {
4
+ chain: Chain;
5
+ rpcUrl: string;
6
+ }
7
+ export declare function lookupNetworkConfig(network: string): NetworkConfig | undefined;
8
+ export declare function isValidPrivateKey(privateKey: string): privateKey is Hex;
3
9
  export interface EvmWallet {
4
10
  network: string;
5
11
  address: Hex;
@@ -7,4 +13,5 @@ export interface EvmWallet {
7
13
  account: ReturnType<typeof privateKeyToAccount>;
8
14
  }
9
15
  export declare function createLocalWallet(network: string, privateKey: string): Promise<EvmWallet>;
16
+ export {};
10
17
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,YAAY,EACjB,KAAK,GAAG,EAGT,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAgCpD,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,GAAG,CAAC;IACb,MAAM,EAAE,YAAY,CAAC;IACrB,OAAO,EAAE,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC;CACjD;AAED,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,SAAS,CAAC,CA2BpB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,YAAY,EACjB,KAAK,GAAG,EACR,KAAK,KAAK,EAEX,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAGpD,UAAU,aAAa;IACrB,KAAK,EAAE,KAAK,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AA0BD,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,6BAElD;AAED,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU,IAAI,GAAG,CAEvE;AAED,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,GAAG,CAAC;IACb,MAAM,EAAE,YAAY,CAAC;IACrB,OAAO,EAAE,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC;CACjD;AAED,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,SAAS,CAAC,CA2BpB"}
package/dist/src/index.js CHANGED
@@ -24,12 +24,18 @@ const NETWORK_CONFIGS = new Map([
24
24
  },
25
25
  ],
26
26
  ]);
27
+ export function lookupNetworkConfig(network) {
28
+ return NETWORK_CONFIGS.get(network);
29
+ }
30
+ export function isValidPrivateKey(privateKey) {
31
+ return isHex(privateKey) && privateKey.length == 66;
32
+ }
27
33
  export async function createLocalWallet(network, privateKey) {
28
- const config = NETWORK_CONFIGS.get(network);
34
+ const config = lookupNetworkConfig(network);
29
35
  if (!config) {
30
36
  throw new Error(`Unsupported network: ${network}. Supported networks: ${Array.from(NETWORK_CONFIGS.keys()).join(", ")}`);
31
37
  }
32
- if (!isHex(privateKey) || privateKey.length !== 66) {
38
+ if (!isValidPrivateKey(privateKey)) {
33
39
  throw new Error(`Invalid private key format. Expected 64-character hex string with '0x' prefix, got: ${privateKey.slice(0, 10)}...`);
34
40
  }
35
41
  const account = privateKeyToAccount(privateKey);