@injectivelabs/wallet-private-key 1.15.6 → 1.15.7

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,13 +1,9 @@
1
1
  import { AccountAddress, EthereumChainId } from '@injectivelabs/ts-types';
2
2
  import { AminoSignResponse, DirectSignResponse } from '@injectivelabs/sdk-ts';
3
- import { StdSignDoc, WalletDeviceType, BaseConcreteStrategy, ConcreteWalletStrategy, SendTransactionOptions, ConcreteEthereumWalletStrategyArgs } from '@injectivelabs/wallet-base';
3
+ import { StdSignDoc, WalletDeviceType, BaseConcreteStrategy, ConcreteWalletStrategy, SendTransactionOptions } from '@injectivelabs/wallet-base';
4
4
  import { TxRaw, TxResponse } from '@injectivelabs/sdk-ts';
5
- interface PrivateKeyArgs extends ConcreteEthereumWalletStrategyArgs {
6
- privateKey?: string;
7
- }
8
5
  export declare class PrivateKeyWallet extends BaseConcreteStrategy implements ConcreteWalletStrategy {
9
6
  private privateKey?;
10
- constructor(args: PrivateKeyArgs);
11
7
  getWalletDeviceType(): Promise<WalletDeviceType>;
12
8
  enable(): Promise<boolean>;
13
9
  disconnect(): Promise<void>;
@@ -37,4 +33,3 @@ export declare class PrivateKeyWallet extends BaseConcreteStrategy implements Co
37
33
  onAccountChange(_callback: (account: AccountAddress | string[]) => void): Promise<void>;
38
34
  private getPrivateKey;
39
35
  }
40
- export {};
@@ -9,12 +9,6 @@ const wallet_base_1 = require("@injectivelabs/wallet-base");
9
9
  const sdk_ts_2 = require("@injectivelabs/sdk-ts");
10
10
  class PrivateKeyWallet extends wallet_base_1.BaseConcreteStrategy {
11
11
  privateKey;
12
- constructor(args) {
13
- super(args);
14
- this.privateKey = args.privateKey
15
- ? sdk_ts_1.PrivateKey.fromHex(args.privateKey)
16
- : undefined;
17
- }
18
12
  async getWalletDeviceType() {
19
13
  return Promise.resolve(wallet_base_1.WalletDeviceType.Other);
20
14
  }
@@ -151,11 +145,14 @@ class PrivateKeyWallet extends wallet_base_1.BaseConcreteStrategy {
151
145
  }
152
146
  getPrivateKey() {
153
147
  if (!this.privateKey) {
154
- throw new exceptions_1.WalletException(new Error('Please provide private key in the constructor'), {
155
- code: exceptions_1.UnspecifiedErrorCode,
156
- type: exceptions_1.ErrorType.WalletNotInstalledError,
157
- contextModule: wallet_base_1.WalletAction.GetAccounts,
158
- });
148
+ if (!this.metadata?.privateKey?.privateKey) {
149
+ throw new exceptions_1.WalletException(new Error('Please provide private key in the constructor'), {
150
+ code: exceptions_1.UnspecifiedErrorCode,
151
+ type: exceptions_1.ErrorType.WalletNotInstalledError,
152
+ contextModule: wallet_base_1.WalletAction.GetAccounts,
153
+ });
154
+ }
155
+ this.privateKey = sdk_ts_1.PrivateKey.fromHex(this.metadata.privateKey.privateKey);
159
156
  }
160
157
  return this.privateKey;
161
158
  }
@@ -1,13 +1,9 @@
1
1
  import { AccountAddress, EthereumChainId } from '@injectivelabs/ts-types';
2
2
  import { AminoSignResponse, DirectSignResponse } from '@injectivelabs/sdk-ts';
3
- import { StdSignDoc, WalletDeviceType, BaseConcreteStrategy, ConcreteWalletStrategy, SendTransactionOptions, ConcreteEthereumWalletStrategyArgs } from '@injectivelabs/wallet-base';
3
+ import { StdSignDoc, WalletDeviceType, BaseConcreteStrategy, ConcreteWalletStrategy, SendTransactionOptions } from '@injectivelabs/wallet-base';
4
4
  import { TxRaw, TxResponse } from '@injectivelabs/sdk-ts';
5
- interface PrivateKeyArgs extends ConcreteEthereumWalletStrategyArgs {
6
- privateKey?: string;
7
- }
8
5
  export declare class PrivateKeyWallet extends BaseConcreteStrategy implements ConcreteWalletStrategy {
9
6
  private privateKey?;
10
- constructor(args: PrivateKeyArgs);
11
7
  getWalletDeviceType(): Promise<WalletDeviceType>;
12
8
  enable(): Promise<boolean>;
13
9
  disconnect(): Promise<void>;
@@ -37,4 +33,3 @@ export declare class PrivateKeyWallet extends BaseConcreteStrategy implements Co
37
33
  onAccountChange(_callback: (account: AccountAddress | string[]) => void): Promise<void>;
38
34
  private getPrivateKey;
39
35
  }
40
- export {};
@@ -6,12 +6,6 @@ import { WalletAction, WalletDeviceType, BaseConcreteStrategy, } from '@injectiv
6
6
  import { toUtf8, TxGrpcApi } from '@injectivelabs/sdk-ts';
7
7
  export class PrivateKeyWallet extends BaseConcreteStrategy {
8
8
  privateKey;
9
- constructor(args) {
10
- super(args);
11
- this.privateKey = args.privateKey
12
- ? PrivateKeySigner.fromHex(args.privateKey)
13
- : undefined;
14
- }
15
9
  async getWalletDeviceType() {
16
10
  return Promise.resolve(WalletDeviceType.Other);
17
11
  }
@@ -148,11 +142,14 @@ export class PrivateKeyWallet extends BaseConcreteStrategy {
148
142
  }
149
143
  getPrivateKey() {
150
144
  if (!this.privateKey) {
151
- throw new WalletException(new Error('Please provide private key in the constructor'), {
152
- code: UnspecifiedErrorCode,
153
- type: ErrorType.WalletNotInstalledError,
154
- contextModule: WalletAction.GetAccounts,
155
- });
145
+ if (!this.metadata?.privateKey?.privateKey) {
146
+ throw new WalletException(new Error('Please provide private key in the constructor'), {
147
+ code: UnspecifiedErrorCode,
148
+ type: ErrorType.WalletNotInstalledError,
149
+ contextModule: WalletAction.GetAccounts,
150
+ });
151
+ }
152
+ this.privateKey = PrivateKeySigner.fromHex(this.metadata.privateKey.privateKey);
156
153
  }
157
154
  return this.privateKey;
158
155
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@injectivelabs/wallet-private-key",
3
3
  "description": "Private key wallet strategy for use with @injectivelabs/wallet-core.",
4
- "version": "1.15.6",
4
+ "version": "1.15.7",
5
5
  "sideEffects": false,
6
6
  "type": "module",
7
7
  "author": {
@@ -56,12 +56,12 @@
56
56
  "start": "node dist/index.js"
57
57
  },
58
58
  "dependencies": {
59
- "@injectivelabs/exceptions": "^1.15.3",
60
- "@injectivelabs/sdk-ts": "^1.15.6",
61
- "@injectivelabs/ts-types": "^1.15.4",
62
- "@injectivelabs/wallet-base": "^1.15.6"
59
+ "@injectivelabs/exceptions": "^1.15.4",
60
+ "@injectivelabs/sdk-ts": "^1.15.7",
61
+ "@injectivelabs/ts-types": "^1.15.5",
62
+ "@injectivelabs/wallet-base": "^1.15.7"
63
63
  },
64
- "gitHead": "de7c94dbd9f169649cab7bcc66d16fa73a2bd8a3",
64
+ "gitHead": "9beac4caf49a97d0d64bde184c4fc603696b81c0",
65
65
  "typedoc": {
66
66
  "entryPoint": "./src/index.ts",
67
67
  "readmeFile": "./README.md",