genlayer-js 0.0.5 → 0.1.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
1
 
2
2
 
3
+ ## 0.1.0 (2024-10-01)
4
+
5
+
6
+ ### Features
7
+
8
+ * expose private key generation and extended account creation from a previous private key ([#10](https://github.com/yeagerai/genlayer-js/issues/10)) ([d43940b](https://github.com/yeagerai/genlayer-js/commit/d43940b7237450a0893823b18b4d0ed2e3e42790))
9
+
3
10
  ## 0.0.5 (2024-09-30)
package/dist/index.cjs CHANGED
@@ -149,8 +149,9 @@ var createClient = (config = { chain: _chunkBAGFDCQEcjs.simulator }) => {
149
149
 
150
150
  // src/accounts/account.ts
151
151
  var _accounts = require('viem/accounts');
152
- var createAccount = () => {
153
- const privateKey = _accounts.generatePrivateKey.call(void 0, );
152
+ var generatePrivateKey = () => _accounts.generatePrivateKey.call(void 0, );
153
+ var createAccount = (accountPrivateKey) => {
154
+ const privateKey = accountPrivateKey || generatePrivateKey();
154
155
  const account = _accounts.privateKeyToAccount.call(void 0, privateKey);
155
156
  return account;
156
157
  };
@@ -158,4 +159,5 @@ var createAccount = () => {
158
159
 
159
160
 
160
161
 
161
- exports.chains = _chunkBAGFDCQEcjs.chains_exports; exports.createAccount = createAccount; exports.createClient = createClient;
162
+
163
+ exports.chains = _chunkBAGFDCQEcjs.chains_exports; exports.createAccount = createAccount; exports.createClient = createClient; exports.generatePrivateKey = generatePrivateKey;
package/dist/index.d.cts CHANGED
@@ -33,7 +33,8 @@ interface ClientConfig {
33
33
  }
34
34
  declare const createClient: (config?: ClientConfig) => GenLayerClient<Transport, SimulatorChain, Account>;
35
35
 
36
- declare const createAccount: () => {
36
+ declare const generatePrivateKey: () => `0x${string}`;
37
+ declare const createAccount: (accountPrivateKey?: `0x${string}`) => {
37
38
  address: viem_accounts.Address;
38
39
  nonceManager?: viem_accounts.NonceManager | undefined;
39
40
  sign: (parameters: {
@@ -52,4 +53,4 @@ declare const createAccount: () => {
52
53
  type: "local";
53
54
  };
54
55
 
55
- export { createAccount, createClient };
56
+ export { createAccount, createClient, generatePrivateKey };
package/dist/index.d.ts CHANGED
@@ -33,7 +33,8 @@ interface ClientConfig {
33
33
  }
34
34
  declare const createClient: (config?: ClientConfig) => GenLayerClient<Transport, SimulatorChain, Account>;
35
35
 
36
- declare const createAccount: () => {
36
+ declare const generatePrivateKey: () => `0x${string}`;
37
+ declare const createAccount: (accountPrivateKey?: `0x${string}`) => {
37
38
  address: viem_accounts.Address;
38
39
  nonceManager?: viem_accounts.NonceManager | undefined;
39
40
  sign: (parameters: {
@@ -52,4 +53,4 @@ declare const createAccount: () => {
52
53
  type: "local";
53
54
  };
54
55
 
55
- export { createAccount, createClient };
56
+ export { createAccount, createClient, generatePrivateKey };
package/dist/index.js CHANGED
@@ -148,14 +148,16 @@ var createClient = (config = { chain: simulator }) => {
148
148
  };
149
149
 
150
150
  // src/accounts/account.ts
151
- import { generatePrivateKey, privateKeyToAccount } from "viem/accounts";
152
- var createAccount = () => {
153
- const privateKey = generatePrivateKey();
151
+ import { generatePrivateKey as _generatePrivateKey, privateKeyToAccount } from "viem/accounts";
152
+ var generatePrivateKey = () => _generatePrivateKey();
153
+ var createAccount = (accountPrivateKey) => {
154
+ const privateKey = accountPrivateKey || generatePrivateKey();
154
155
  const account = privateKeyToAccount(privateKey);
155
156
  return account;
156
157
  };
157
158
  export {
158
159
  chains_exports as chains,
159
160
  createAccount,
160
- createClient
161
+ createClient,
162
+ generatePrivateKey
161
163
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "genlayer-js",
3
3
  "type": "module",
4
- "version": "0.0.5",
4
+ "version": "0.1.0",
5
5
  "description": "GenLayer JavaScript SDK",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -1,7 +1,9 @@
1
- import {generatePrivateKey, privateKeyToAccount} from "viem/accounts";
1
+ import {generatePrivateKey as _generatePrivateKey, privateKeyToAccount} from "viem/accounts";
2
2
 
3
- export const createAccount = () => {
4
- const privateKey = generatePrivateKey();
3
+ export const generatePrivateKey = () => _generatePrivateKey();
4
+
5
+ export const createAccount = (accountPrivateKey?: `0x${string}`) => {
6
+ const privateKey = accountPrivateKey || generatePrivateKey();
5
7
  const account = privateKeyToAccount(privateKey);
6
8
  return account;
7
9
  };
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  // src/index.ts
2
2
  export {createClient} from "./client/client";
3
- export {createAccount} from "./accounts/account";
3
+ export {createAccount, generatePrivateKey} from "./accounts/account";
4
4
  export * as chains from "./chains";