@injectivelabs/wallet-private-key 1.16.12 → 1.16.13-alpha.1

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/README.md CHANGED
@@ -30,9 +30,9 @@ dependencies and implementations for their specific wallets.
30
30
  Here's a brief example of how to use this package to send 1 INJ.:
31
31
 
32
32
  ```typescript
33
- import { Wallet } from '@injectivelabs/wallet-base';
34
- import { BaseWalletStrategy, MsgBroadcaster } from '@injectivelabs/wallet-core';
35
- import { PrivateKeyWalletStrategy } from '@injectivelabs/wallet-private-key';
33
+ import { Wallet } from '@injectivelabs/wallet-base'
34
+ import { BaseWalletStrategy, MsgBroadcaster } from '@injectivelabs/wallet-core'
35
+ import { PrivateKeyWalletStrategy } from '@injectivelabs/wallet-private-key'
36
36
 
37
37
 
38
38
  const strategyArgs: WalletStrategyArguments = {
@@ -1,7 +1,8 @@
1
- import { AminoSignResponse, DirectSignResponse } from '@injectivelabs/sdk-ts';
2
- import { StdSignDoc, WalletDeviceType, BaseConcreteStrategy, ConcreteWalletStrategy, SendTransactionOptions } from '@injectivelabs/wallet-base';
3
- import { TxRaw, TxResponse } from '@injectivelabs/sdk-ts';
4
- import { EvmChainId, AccountAddress } from '@injectivelabs/ts-types';
1
+ import { EvmChainId } from '@injectivelabs/ts-types';
2
+ import { WalletDeviceType, BaseConcreteStrategy } from '@injectivelabs/wallet-base';
3
+ import type { AccountAddress } from '@injectivelabs/ts-types';
4
+ import type { TxRaw, TxResponse, AminoSignResponse, DirectSignResponse } from '@injectivelabs/sdk-ts';
5
+ import type { StdSignDoc, ConcreteWalletStrategy, SendTransactionOptions } from '@injectivelabs/wallet-base';
5
6
  export declare class PrivateKeyWallet extends BaseConcreteStrategy implements ConcreteWalletStrategy {
6
7
  private privateKey?;
7
8
  getWalletDeviceType(): Promise<WalletDeviceType>;
@@ -1,12 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PrivateKeyWallet = void 0;
4
- /* eslint-disable class-methods-use-this */
5
4
  const sdk_ts_1 = require("@injectivelabs/sdk-ts");
6
- const exceptions_1 = require("@injectivelabs/exceptions");
7
- const wallet_base_1 = require("@injectivelabs/wallet-base");
8
- const sdk_ts_2 = require("@injectivelabs/sdk-ts");
9
5
  const ts_types_1 = require("@injectivelabs/ts-types");
6
+ const sdk_ts_2 = require("@injectivelabs/sdk-ts");
7
+ const wallet_base_1 = require("@injectivelabs/wallet-base");
8
+ const exceptions_1 = require("@injectivelabs/exceptions");
10
9
  class PrivateKeyWallet extends wallet_base_1.BaseConcreteStrategy {
11
10
  privateKey;
12
11
  async getWalletDeviceType() {
@@ -31,7 +30,6 @@ class PrivateKeyWallet extends wallet_base_1.BaseConcreteStrategy {
31
30
  });
32
31
  }
33
32
  }
34
- // eslint-disable-next-line class-methods-use-this
35
33
  async getSessionOrConfirm(address) {
36
34
  return Promise.resolve(`0x${Buffer.from(`Confirmation for ${address} at time: ${Date.now()}`).toString('hex')}`);
37
35
  }
@@ -47,7 +45,7 @@ class PrivateKeyWallet extends wallet_base_1.BaseConcreteStrategy {
47
45
  if (!endpoints) {
48
46
  throw new exceptions_1.WalletException(new Error('You have to pass endpoints within the options for using Ethereum native wallets'));
49
47
  }
50
- const txApi = new sdk_ts_2.TxGrpcApi(endpoints.grpc);
48
+ const txApi = new sdk_ts_1.TxGrpcApi(endpoints.grpc);
51
49
  const response = await txApi.broadcast(transaction, { txTimeout });
52
50
  if (response.code !== 0) {
53
51
  throw new exceptions_1.TransactionException(new Error(response.rawLog), {
@@ -60,7 +58,7 @@ class PrivateKeyWallet extends wallet_base_1.BaseConcreteStrategy {
60
58
  }
61
59
  async signEip712TypedData(eip712json, address) {
62
60
  const pk = this.getPrivateKey();
63
- if ((0, sdk_ts_1.getInjectiveSignerAddress)(address) !== pk.toAddress().toBech32()) {
61
+ if ((0, sdk_ts_2.getInjectiveSignerAddress)(address) !== pk.toAddress().toBech32()) {
64
62
  throw new exceptions_1.WalletException(new Error('Signer address does not match the private key address'), {
65
63
  code: exceptions_1.UnspecifiedErrorCode,
66
64
  type: exceptions_1.ErrorType.WalletError,
@@ -86,7 +84,6 @@ class PrivateKeyWallet extends wallet_base_1.BaseConcreteStrategy {
86
84
  contextModule: wallet_base_1.WalletAction.SignTransaction,
87
85
  });
88
86
  }
89
- // eslint-disable-next-line class-methods-use-this
90
87
  async signCosmosTransaction(_transaction) {
91
88
  throw new exceptions_1.WalletException(new Error('This wallet does not support signing Cosmos transactions'), {
92
89
  code: exceptions_1.UnspecifiedErrorCode,
@@ -96,7 +93,7 @@ class PrivateKeyWallet extends wallet_base_1.BaseConcreteStrategy {
96
93
  }
97
94
  async signArbitrary(signer, data) {
98
95
  const pk = this.getPrivateKey();
99
- if ((0, sdk_ts_1.getInjectiveSignerAddress)(signer) !== pk.toAddress().toBech32()) {
96
+ if ((0, sdk_ts_2.getInjectiveSignerAddress)(signer) !== pk.toAddress().toBech32()) {
100
97
  throw new exceptions_1.WalletException(new Error('Signer address does not match the private key address'), {
101
98
  code: exceptions_1.UnspecifiedErrorCode,
102
99
  type: exceptions_1.ErrorType.WalletError,
@@ -104,7 +101,7 @@ class PrivateKeyWallet extends wallet_base_1.BaseConcreteStrategy {
104
101
  });
105
102
  }
106
103
  try {
107
- const signature = await pk.signHashed(Buffer.from((0, sdk_ts_2.toUtf8)(data), 'utf-8'));
104
+ const signature = await pk.signHashed(Buffer.from((0, sdk_ts_1.toUtf8)(data), 'utf-8'));
108
105
  return `0x${Buffer.from(signature).toString('base64')}`;
109
106
  }
110
107
  catch (e) {
@@ -132,7 +129,6 @@ class PrivateKeyWallet extends wallet_base_1.BaseConcreteStrategy {
132
129
  async getEvmTransactionReceipt(_txHash) {
133
130
  throw new exceptions_1.WalletException(new Error('Not supported'));
134
131
  }
135
- // eslint-disable-next-line class-methods-use-this
136
132
  async getPubKey() {
137
133
  const pk = this.getPrivateKey();
138
134
  return pk.toPublicKey().toBase64();
@@ -152,7 +148,7 @@ class PrivateKeyWallet extends wallet_base_1.BaseConcreteStrategy {
152
148
  contextModule: wallet_base_1.WalletAction.GetAccounts,
153
149
  });
154
150
  }
155
- this.privateKey = sdk_ts_1.PrivateKey.fromHex(this.metadata.privateKey.privateKey);
151
+ this.privateKey = sdk_ts_2.PrivateKey.fromHex(this.metadata.privateKey.privateKey);
156
152
  }
157
153
  return this.privateKey;
158
154
  }
@@ -1,7 +1,8 @@
1
- import { AminoSignResponse, DirectSignResponse } from '@injectivelabs/sdk-ts';
2
- import { StdSignDoc, WalletDeviceType, BaseConcreteStrategy, ConcreteWalletStrategy, SendTransactionOptions } from '@injectivelabs/wallet-base';
3
- import { TxRaw, TxResponse } from '@injectivelabs/sdk-ts';
4
- import { EvmChainId, AccountAddress } from '@injectivelabs/ts-types';
1
+ import { EvmChainId } from '@injectivelabs/ts-types';
2
+ import { WalletDeviceType, BaseConcreteStrategy } from '@injectivelabs/wallet-base';
3
+ import type { AccountAddress } from '@injectivelabs/ts-types';
4
+ import type { TxRaw, TxResponse, AminoSignResponse, DirectSignResponse } from '@injectivelabs/sdk-ts';
5
+ import type { StdSignDoc, ConcreteWalletStrategy, SendTransactionOptions } from '@injectivelabs/wallet-base';
5
6
  export declare class PrivateKeyWallet extends BaseConcreteStrategy implements ConcreteWalletStrategy {
6
7
  private privateKey?;
7
8
  getWalletDeviceType(): Promise<WalletDeviceType>;
@@ -1,9 +1,8 @@
1
- /* eslint-disable class-methods-use-this */
2
- import { getInjectiveSignerAddress, PrivateKey as PrivateKeySigner, } from '@injectivelabs/sdk-ts';
3
- import { ErrorType, WalletException, MetamaskException, UnspecifiedErrorCode, TransactionException, } from '@injectivelabs/exceptions';
4
- import { WalletAction, WalletDeviceType, BaseConcreteStrategy, } from '@injectivelabs/wallet-base';
5
1
  import { toUtf8, TxGrpcApi } from '@injectivelabs/sdk-ts';
6
2
  import { ChainId, EvmChainId } from '@injectivelabs/ts-types';
3
+ import { getInjectiveSignerAddress, PrivateKey as PrivateKeySigner, } from '@injectivelabs/sdk-ts';
4
+ import { WalletAction, WalletDeviceType, BaseConcreteStrategy, } from '@injectivelabs/wallet-base';
5
+ import { ErrorType, WalletException, MetamaskException, UnspecifiedErrorCode, TransactionException, } from '@injectivelabs/exceptions';
7
6
  export class PrivateKeyWallet extends BaseConcreteStrategy {
8
7
  privateKey;
9
8
  async getWalletDeviceType() {
@@ -28,7 +27,6 @@ export class PrivateKeyWallet extends BaseConcreteStrategy {
28
27
  });
29
28
  }
30
29
  }
31
- // eslint-disable-next-line class-methods-use-this
32
30
  async getSessionOrConfirm(address) {
33
31
  return Promise.resolve(`0x${Buffer.from(`Confirmation for ${address} at time: ${Date.now()}`).toString('hex')}`);
34
32
  }
@@ -83,7 +81,6 @@ export class PrivateKeyWallet extends BaseConcreteStrategy {
83
81
  contextModule: WalletAction.SignTransaction,
84
82
  });
85
83
  }
86
- // eslint-disable-next-line class-methods-use-this
87
84
  async signCosmosTransaction(_transaction) {
88
85
  throw new WalletException(new Error('This wallet does not support signing Cosmos transactions'), {
89
86
  code: UnspecifiedErrorCode,
@@ -129,7 +126,6 @@ export class PrivateKeyWallet extends BaseConcreteStrategy {
129
126
  async getEvmTransactionReceipt(_txHash) {
130
127
  throw new WalletException(new Error('Not supported'));
131
128
  }
132
- // eslint-disable-next-line class-methods-use-this
133
129
  async getPubKey() {
134
130
  const pk = this.getPrivateKey();
135
131
  return pk.toPublicKey().toBase64();
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.16.12",
4
+ "version": "1.16.13-alpha.1",
5
5
  "sideEffects": false,
6
6
  "type": "module",
7
7
  "author": {
@@ -56,15 +56,15 @@
56
56
  "start": "node dist/index.js"
57
57
  },
58
58
  "dependencies": {
59
- "@injectivelabs/exceptions": "1.16.12",
60
- "@injectivelabs/sdk-ts": "1.16.12",
61
- "@injectivelabs/ts-types": "1.16.12",
62
- "@injectivelabs/wallet-base": "1.16.12"
59
+ "@injectivelabs/exceptions": "1.16.13-alpha.1",
60
+ "@injectivelabs/sdk-ts": "1.16.13-alpha.1",
61
+ "@injectivelabs/ts-types": "1.16.13-alpha.1",
62
+ "@injectivelabs/wallet-base": "1.16.13-alpha.1"
63
63
  },
64
64
  "devDependencies": {
65
65
  "shx": "^0.3.4"
66
66
  },
67
- "gitHead": "11a4cd78ffb176786df6c4aff98476f90f0b354b",
67
+ "gitHead": "feb3e8f6bd6fa67bb489c94f6373a8d68a9846ae",
68
68
  "typedoc": {
69
69
  "entryPoint": "./src/index.ts",
70
70
  "readmeFile": "./README.md",