@injectivelabs/wallet-private-key 0.0.2

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 ADDED
@@ -0,0 +1,112 @@
1
+ # 🌟 Injective Protocol - Private Wallet Strategy
2
+
3
+ <!-- TODO -->
4
+
5
+ [![downloads](https://img.shields.io/npm/dm/@injectivelabs/wallet-ts.svg)](https://www.npmjs.com/package/@injectivelabs/wallet-ts)
6
+ [![npm-version](https://img.shields.io/npm/v/@injectivelabs/wallet-ts.svg)](https://www.npmjs.com/package/@injectivelabs/wallet-ts)
7
+ [![license](https://img.shields.io/npm/l/express.svg)]()
8
+
9
+ _Package to use Private Wallet on Injective via the wallet strategy._
10
+
11
+ ---
12
+
13
+ ## 📚 Installation
14
+
15
+ ```bash
16
+ yarn add @injectivelabs/wallet-evm
17
+ ```
18
+
19
+ ---
20
+
21
+ ## 📖 Documentation
22
+
23
+ Injective's wallet packages are intended to make it easy for developers to choose exactly what wallets - and subsequent dependencies - they
24
+ want to include in their projects.
25
+
26
+ Regardless of which wallet package(s) you choose to use you must also have `@injectivelabs/wallet-core` and `@injectivelabs/wallet-base`
27
+ installed. These contain all of the types and core wallet functionality, with the separate wallet packages only providing the necessary
28
+ dependencies and implementations for their specific wallets.
29
+
30
+ Here's a brief example of how to use this package to send 1 INJ.:
31
+
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';
36
+
37
+
38
+ const strategyArgs: WalletStrategyArguments = {
39
+ chainId: ChainId.Mainnet,
40
+ wallet: Wallet.PrivateKey,
41
+ strategies: {
42
+ [Wallet.PrivateKey]: new PrivateKeyWalletStrategy({
43
+ chainId: ChainId.Mainnet,
44
+ privateKey: 'YOUR_PRIVATE_KEY'
45
+ ethereumOptions: {
46
+ ethereumChainId: EthereumChainId.Mainnet,
47
+ },
48
+ }),
49
+ },
50
+ }
51
+ const walletStrategy = new BaseWalletStrategy(strategyArgs)
52
+
53
+ const msgBroadcaster = new MsgBroadcaster({
54
+ walletStrategy,
55
+ simulateTx: true,
56
+ network: Network.Mainnet,
57
+ })
58
+
59
+ const sendTX = async () => {
60
+ const injectiveAddress = 'someInjectiveAddress'
61
+
62
+ const message = MsgSend.fromJSON({
63
+ srcInjectiveAddress: injectiveAddress,
64
+ dstInjectiveAddress: injectiveAddress,
65
+ amount: {
66
+ amount: '1',
67
+ denom: 'inj',
68
+ },
69
+ })
70
+
71
+ return await msgBroadcaster.broadcast({ msgs: message })
72
+ }
73
+
74
+ const result = await sendTX()
75
+ ```
76
+
77
+ Read more and find example usages on our [WalletStrategy Docs](https://docs.ts.injective.network/wallet/wallet-wallet-strategy)
78
+
79
+ ---
80
+
81
+ ## 📜 Contribution
82
+
83
+ **Contribution guides and practices will be available once there is a stable foundation of the whole package set within the `injective-ts` repo.**
84
+
85
+ ---
86
+
87
+ ## ⛑ Support
88
+
89
+ Reach out to us at one of the following places!
90
+
91
+ - Website at <a href="https://injective.com" target="_blank">`injective.com`</a>
92
+ - Twitter at <a href="https://twitter.com/Injective_" target="_blank">`@Injective`</a>
93
+ - Discord at <a href="https://discord.com/invite/NK4qdbv" target="_blank">`Discord`</a>
94
+ - Telegram at <a href="https://t.me/joininjective" target="_blank">`Telegram`</a>
95
+
96
+ ---
97
+
98
+ ## 🔓 License
99
+
100
+ Copyright © 2021 - 2022 Injective Labs Inc. (https://injectivelabs.org/)
101
+
102
+ <a href="https://iili.io/mNneZN.md.png"><img src="https://iili.io/mNneZN.md.png" style="width: 300px; max-width: 100%; height: auto" />
103
+
104
+ Originally released by Injective Labs Inc. under: <br />
105
+ Apache License <br />
106
+ Version 2.0, January 2004 <br />
107
+ http://www.apache.org/licenses/
108
+
109
+ <p>&nbsp;</p>
110
+ <div align="center">
111
+ <sub><em>Powering the future of decentralized finance.</em></sub>
112
+ </div>
@@ -0,0 +1,2 @@
1
+ export { PrivateKeyWallet as PrivateKeyWalletStrategy } from './strategy/strategy';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,IAAI,wBAAwB,EAAE,MAAM,qBAAqB,CAAA"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PrivateKeyWalletStrategy = void 0;
4
+ var strategy_1 = require("./strategy/strategy");
5
+ Object.defineProperty(exports, "PrivateKeyWalletStrategy", { enumerable: true, get: function () { return strategy_1.PrivateKeyWallet; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,gDAAkF;AAAzE,oHAAA,gBAAgB,OAA4B"}
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -0,0 +1,41 @@
1
+ import { AccountAddress, EthereumChainId } from '@injectivelabs/ts-types';
2
+ import { AminoSignResponse, DirectSignResponse } from '@injectivelabs/sdk-ts';
3
+ import { StdSignDoc, WalletDeviceType, BaseConcreteStrategy, ConcreteWalletStrategy, SendTransactionOptions, ConcreteEthereumWalletStrategyArgs } from '@injectivelabs/wallet-base';
4
+ import { TxRaw, TxResponse } from '@injectivelabs/sdk-ts';
5
+ interface PrivateKeyArgs extends ConcreteEthereumWalletStrategyArgs {
6
+ privateKey?: string;
7
+ }
8
+ export declare class PrivateKeyWallet extends BaseConcreteStrategy implements ConcreteWalletStrategy {
9
+ private privateKey?;
10
+ constructor(args: PrivateKeyArgs);
11
+ getWalletDeviceType(): Promise<WalletDeviceType>;
12
+ enable(): Promise<boolean>;
13
+ disconnect(): Promise<void>;
14
+ getAddresses(): Promise<string[]>;
15
+ getSessionOrConfirm(address: AccountAddress): Promise<string>;
16
+ sendEthereumTransaction(_transaction: unknown, _options: {
17
+ address: AccountAddress;
18
+ ethereumChainId: EthereumChainId;
19
+ }): Promise<string>;
20
+ sendTransaction(transaction: TxRaw, options: SendTransactionOptions): Promise<TxResponse>;
21
+ signEip712TypedData(eip712json: string, address: AccountAddress): Promise<string>;
22
+ signAminoCosmosTransaction(_transaction: {
23
+ address: string;
24
+ signDoc: StdSignDoc;
25
+ }): Promise<AminoSignResponse>;
26
+ signCosmosTransaction(_transaction: {
27
+ txRaw: TxRaw;
28
+ accountNumber: number;
29
+ chainId: string;
30
+ address: string;
31
+ }): Promise<DirectSignResponse>;
32
+ signArbitrary(signer: AccountAddress, data: string | Uint8Array): Promise<string>;
33
+ getEthereumChainId(): Promise<string>;
34
+ getEthereumTransactionReceipt(_txHash: string): Promise<string>;
35
+ getPubKey(): Promise<string>;
36
+ onChainIdChanged(_callback: (chain: string) => void): Promise<void>;
37
+ onAccountChange(_callback: (account: AccountAddress) => void): Promise<void>;
38
+ private getPrivateKey;
39
+ }
40
+ export {};
41
+ //# sourceMappingURL=strategy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"strategy.d.ts","sourceRoot":"","sources":["../../../src/strategy/strategy.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,cAAc,EACd,eAAe,EAChB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAGnB,MAAM,uBAAuB,CAAA;AAQ9B,OAAO,EACL,UAAU,EAEV,gBAAgB,EAChB,oBAAoB,EACpB,sBAAsB,EACtB,sBAAsB,EACtB,kCAAkC,EACnC,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAE,KAAK,EAAqB,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAE5E,UAAU,cAAe,SAAQ,kCAAkC;IACjE,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED,qBAAa,gBACX,SAAQ,oBACR,YAAW,sBAAsB;IAEjC,OAAO,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SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAInE,eAAe,CACnB,SAAS,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,IAAI,GAC3C,OAAO,CAAC,IAAI,CAAC;IAIhB,OAAO,CAAC,aAAa;CActB"}
@@ -0,0 +1,204 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.PrivateKeyWallet = void 0;
13
+ /* eslint-disable class-methods-use-this */
14
+ const ts_types_1 = require("@injectivelabs/ts-types");
15
+ const sdk_ts_1 = require("@injectivelabs/sdk-ts");
16
+ const exceptions_1 = require("@injectivelabs/exceptions");
17
+ const wallet_base_1 = require("@injectivelabs/wallet-base");
18
+ const sdk_ts_2 = require("@injectivelabs/sdk-ts");
19
+ class PrivateKeyWallet extends wallet_base_1.BaseConcreteStrategy {
20
+ constructor(args) {
21
+ super(args);
22
+ this.privateKey = args.privateKey
23
+ ? sdk_ts_1.PrivateKey.fromHex(args.privateKey)
24
+ : undefined;
25
+ }
26
+ getWalletDeviceType() {
27
+ return __awaiter(this, void 0, void 0, function* () {
28
+ return Promise.resolve(wallet_base_1.WalletDeviceType.Other);
29
+ });
30
+ }
31
+ enable() {
32
+ return __awaiter(this, void 0, void 0, function* () {
33
+ return Promise.resolve(true);
34
+ });
35
+ }
36
+ disconnect() {
37
+ return __awaiter(this, void 0, void 0, function* () {
38
+ this.listeners = {};
39
+ });
40
+ }
41
+ getAddresses() {
42
+ return __awaiter(this, void 0, void 0, function* () {
43
+ const pk = this.getPrivateKey();
44
+ try {
45
+ return Promise.resolve([pk.toAddress().toHex()]);
46
+ }
47
+ catch (e) {
48
+ throw new exceptions_1.MetamaskException(new Error(e.message), {
49
+ code: exceptions_1.UnspecifiedErrorCode,
50
+ type: exceptions_1.ErrorType.WalletError,
51
+ contextModule: wallet_base_1.WalletAction.GetAccounts,
52
+ });
53
+ }
54
+ });
55
+ }
56
+ // eslint-disable-next-line class-methods-use-this
57
+ getSessionOrConfirm(address) {
58
+ return __awaiter(this, void 0, void 0, function* () {
59
+ return Promise.resolve(`0x${Buffer.from(`Confirmation for ${address} at time: ${Date.now()}`).toString('hex')}`);
60
+ });
61
+ }
62
+ sendEthereumTransaction(_transaction, _options) {
63
+ return __awaiter(this, void 0, void 0, function* () {
64
+ throw new exceptions_1.WalletException(new Error('This wallet does not support sending Ethereum transactions'), {
65
+ code: exceptions_1.UnspecifiedErrorCode,
66
+ type: exceptions_1.ErrorType.WalletError,
67
+ contextModule: wallet_base_1.WalletAction.SendEthereumTransaction,
68
+ });
69
+ });
70
+ }
71
+ sendTransaction(transaction, options) {
72
+ return __awaiter(this, void 0, void 0, function* () {
73
+ const { endpoints, txTimeout } = options;
74
+ if (!endpoints) {
75
+ throw new exceptions_1.WalletException(new Error('You have to pass endpoints within the options for using Ethereum native wallets'));
76
+ }
77
+ const txApi = new sdk_ts_2.TxGrpcApi(endpoints.grpc);
78
+ const response = yield txApi.broadcast(transaction, { txTimeout });
79
+ if (response.code !== 0) {
80
+ throw new exceptions_1.TransactionException(new Error(response.rawLog), {
81
+ code: exceptions_1.UnspecifiedErrorCode,
82
+ contextCode: response.code,
83
+ contextModule: response.codespace,
84
+ });
85
+ }
86
+ return response;
87
+ });
88
+ }
89
+ signEip712TypedData(eip712json, address) {
90
+ return __awaiter(this, void 0, void 0, function* () {
91
+ const pk = this.getPrivateKey();
92
+ if ((0, sdk_ts_1.getInjectiveSignerAddress)(address) !== pk.toAddress().toBech32()) {
93
+ throw new exceptions_1.WalletException(new Error('Signer address does not match the private key address'), {
94
+ code: exceptions_1.UnspecifiedErrorCode,
95
+ type: exceptions_1.ErrorType.WalletError,
96
+ contextModule: wallet_base_1.WalletAction.SignTransaction,
97
+ });
98
+ }
99
+ try {
100
+ const signature = yield pk.signTypedData(JSON.parse(eip712json));
101
+ return `0x${Buffer.from(signature).toString('hex')}`;
102
+ }
103
+ catch (e) {
104
+ throw new exceptions_1.MetamaskException(new Error(e.message), {
105
+ code: exceptions_1.UnspecifiedErrorCode,
106
+ type: exceptions_1.ErrorType.WalletError,
107
+ contextModule: wallet_base_1.WalletAction.SignTransaction,
108
+ });
109
+ }
110
+ });
111
+ }
112
+ signAminoCosmosTransaction(_transaction) {
113
+ return __awaiter(this, void 0, void 0, function* () {
114
+ throw new exceptions_1.WalletException(new Error('This wallet does not support signing Cosmos transactions'), {
115
+ code: exceptions_1.UnspecifiedErrorCode,
116
+ type: exceptions_1.ErrorType.WalletError,
117
+ contextModule: wallet_base_1.WalletAction.SignTransaction,
118
+ });
119
+ });
120
+ }
121
+ // eslint-disable-next-line class-methods-use-this
122
+ signCosmosTransaction(_transaction) {
123
+ return __awaiter(this, void 0, void 0, function* () {
124
+ throw new exceptions_1.WalletException(new Error('This wallet does not support signing Cosmos transactions'), {
125
+ code: exceptions_1.UnspecifiedErrorCode,
126
+ type: exceptions_1.ErrorType.WalletError,
127
+ contextModule: wallet_base_1.WalletAction.SignTransaction,
128
+ });
129
+ });
130
+ }
131
+ signArbitrary(signer, data) {
132
+ return __awaiter(this, void 0, void 0, function* () {
133
+ const pk = this.getPrivateKey();
134
+ if ((0, sdk_ts_1.getInjectiveSignerAddress)(signer) !== pk.toAddress().toBech32()) {
135
+ throw new exceptions_1.WalletException(new Error('Signer address does not match the private key address'), {
136
+ code: exceptions_1.UnspecifiedErrorCode,
137
+ type: exceptions_1.ErrorType.WalletError,
138
+ contextModule: wallet_base_1.WalletAction.SignArbitrary,
139
+ });
140
+ }
141
+ try {
142
+ const signature = yield pk.signHashed(Buffer.from((0, sdk_ts_2.toUtf8)(data), 'utf-8'));
143
+ return `0x${Buffer.from(signature).toString('base64')}`;
144
+ }
145
+ catch (e) {
146
+ throw new exceptions_1.MetamaskException(new Error(e.message), {
147
+ code: exceptions_1.UnspecifiedErrorCode,
148
+ type: exceptions_1.ErrorType.WalletError,
149
+ contextModule: wallet_base_1.WalletAction.SignArbitrary,
150
+ });
151
+ }
152
+ });
153
+ }
154
+ getEthereumChainId() {
155
+ return __awaiter(this, void 0, void 0, function* () {
156
+ try {
157
+ return Promise.resolve((this.chainId === ts_types_1.ChainId.Mainnet
158
+ ? ts_types_1.EthereumChainId.Mainnet
159
+ : ts_types_1.EthereumChainId.Sepolia).toString(16));
160
+ }
161
+ catch (e) {
162
+ throw new exceptions_1.MetamaskException(new Error(e.message), {
163
+ code: exceptions_1.UnspecifiedErrorCode,
164
+ type: exceptions_1.ErrorType.WalletError,
165
+ contextModule: wallet_base_1.WalletAction.GetChainId,
166
+ });
167
+ }
168
+ });
169
+ }
170
+ getEthereumTransactionReceipt(_txHash) {
171
+ return __awaiter(this, void 0, void 0, function* () {
172
+ throw new exceptions_1.WalletException(new Error('Not supported'));
173
+ });
174
+ }
175
+ // eslint-disable-next-line class-methods-use-this
176
+ getPubKey() {
177
+ return __awaiter(this, void 0, void 0, function* () {
178
+ const pk = this.getPrivateKey();
179
+ return pk.toPublicKey().toBase64();
180
+ });
181
+ }
182
+ onChainIdChanged(_callback) {
183
+ return __awaiter(this, void 0, void 0, function* () {
184
+ //
185
+ });
186
+ }
187
+ onAccountChange(_callback) {
188
+ return __awaiter(this, void 0, void 0, function* () {
189
+ //
190
+ });
191
+ }
192
+ getPrivateKey() {
193
+ if (!this.privateKey) {
194
+ throw new exceptions_1.WalletException(new Error('Please provide private key in the constructor'), {
195
+ code: exceptions_1.UnspecifiedErrorCode,
196
+ type: exceptions_1.ErrorType.WalletNotInstalledError,
197
+ contextModule: wallet_base_1.WalletAction.GetAccounts,
198
+ });
199
+ }
200
+ return this.privateKey;
201
+ }
202
+ }
203
+ exports.PrivateKeyWallet = PrivateKeyWallet;
204
+ //# sourceMappingURL=strategy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"strategy.js","sourceRoot":"","sources":["../../../src/strategy/strategy.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA2C;AAC3C,sDAIgC;AAChC,kDAK8B;AAC9B,0DAMkC;AAClC,4DAQmC;AACnC,kDAA4E;AAM5E,MAAa,gBACX,SAAQ,kCAAoB;IAK5B,YAAY,IAAoB;QAC9B,KAAK,CAAC,IAAI,CAAC,CAAA;QAEX,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU;YAC/B,CAAC,CAAC,mBAAgB,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC;YAC3C,CAAC,CAAC,SAAS,CAAA;IACf,CAAC;IAEK,mBAAmB;;YACvB,OAAO,OAAO,CAAC,OAAO,CAAC,8BAAgB,CAAC,KAAK,CAAC,CAAA;QAChD,CAAC;KAAA;IAEK,MAAM;;YACV,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;QAC9B,CAAC;KAAA;IAEY,UAAU;;YACrB,IAAI,CAAC,SAAS,GAAG,EAAE,CAAA;QACrB,CAAC;KAAA;IAEK,YAAY;;YAChB,MAAM,EAAE,GAAG,IAAI,CAAC,aAAa,EAAE,CAAA;YAE/B,IAAI,CAAC;gBACH,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;YAClD,CAAC;YAAC,OAAO,CAAU,EAAE,CAAC;gBACpB,MAAM,IAAI,8BAAiB,CAAC,IAAI,KAAK,CAAE,CAAS,CAAC,OAAO,CAAC,EAAE;oBACzD,IAAI,EAAE,iCAAoB;oBAC1B,IAAI,E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,2 @@
1
+ export { PrivateKeyWallet as PrivateKeyWalletStrategy } from './strategy/strategy';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,IAAI,wBAAwB,EAAE,MAAM,qBAAqB,CAAA"}
@@ -0,0 +1,2 @@
1
+ export { PrivateKeyWallet as PrivateKeyWalletStrategy } from './strategy/strategy';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,IAAI,wBAAwB,EAAE,MAAM,qBAAqB,CAAA"}
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
@@ -0,0 +1,41 @@
1
+ import { AccountAddress, EthereumChainId } from '@injectivelabs/ts-types';
2
+ import { AminoSignResponse, DirectSignResponse } from '@injectivelabs/sdk-ts';
3
+ import { StdSignDoc, WalletDeviceType, BaseConcreteStrategy, ConcreteWalletStrategy, SendTransactionOptions, ConcreteEthereumWalletStrategyArgs } from '@injectivelabs/wallet-base';
4
+ import { TxRaw, TxResponse } from '@injectivelabs/sdk-ts';
5
+ interface PrivateKeyArgs extends ConcreteEthereumWalletStrategyArgs {
6
+ privateKey?: string;
7
+ }
8
+ export declare class PrivateKeyWallet extends BaseConcreteStrategy implements ConcreteWalletStrategy {
9
+ private privateKey?;
10
+ constructor(args: PrivateKeyArgs);
11
+ getWalletDeviceType(): Promise<WalletDeviceType>;
12
+ enable(): Promise<boolean>;
13
+ disconnect(): Promise<void>;
14
+ getAddresses(): Promise<string[]>;
15
+ getSessionOrConfirm(address: AccountAddress): Promise<string>;
16
+ sendEthereumTransaction(_transaction: unknown, _options: {
17
+ address: AccountAddress;
18
+ ethereumChainId: EthereumChainId;
19
+ }): Promise<string>;
20
+ sendTransaction(transaction: TxRaw, options: SendTransactionOptions): Promise<TxResponse>;
21
+ signEip712TypedData(eip712json: string, address: AccountAddress): Promise<string>;
22
+ signAminoCosmosTransaction(_transaction: {
23
+ address: string;
24
+ signDoc: StdSignDoc;
25
+ }): Promise<AminoSignResponse>;
26
+ signCosmosTransaction(_transaction: {
27
+ txRaw: TxRaw;
28
+ accountNumber: number;
29
+ chainId: string;
30
+ address: string;
31
+ }): Promise<DirectSignResponse>;
32
+ signArbitrary(signer: AccountAddress, data: string | Uint8Array): Promise<string>;
33
+ getEthereumChainId(): Promise<string>;
34
+ getEthereumTransactionReceipt(_txHash: string): Promise<string>;
35
+ getPubKey(): Promise<string>;
36
+ onChainIdChanged(_callback: (chain: string) => void): Promise<void>;
37
+ onAccountChange(_callback: (account: AccountAddress) => void): Promise<void>;
38
+ private getPrivateKey;
39
+ }
40
+ export {};
41
+ //# sourceMappingURL=strategy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"strategy.d.ts","sourceRoot":"","sources":["../../../src/strategy/strategy.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,cAAc,EACd,eAAe,EAChB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAGnB,MAAM,uBAAuB,CAAA;AAQ9B,OAAO,EACL,UAAU,EAEV,gBAAgB,EAChB,oBAAoB,EACpB,sBAAsB,EACtB,sBAAsB,EACtB,kCAAkC,EACnC,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAE,KAAK,EAAqB,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAE5E,UAAU,cAAe,SAAQ,kCAAkC;IACjE,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED,qBAAa,gBACX,SAAQ,oBACR,YAAW,sBAAsB;IAEjC,OAAO,CAAC,UAAU,CAAC,CAA8B;gBAErC,IAAI,EAAE,cAAc;IAQ1B,mBAAmB,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAIhD,MAAM,IAAI,OAAO,CAA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Ac,KAAK,IAAI,GAC3C,OAAO,CAAC,IAAI,CAAC;IAIhB,OAAO,CAAC,aAAa;CActB"}
@@ -0,0 +1,160 @@
1
+ /* eslint-disable class-methods-use-this */
2
+ import { ChainId, EthereumChainId, } from '@injectivelabs/ts-types';
3
+ import { PrivateKey as PrivateKeySigner, getInjectiveSignerAddress, } from '@injectivelabs/sdk-ts';
4
+ import { ErrorType, WalletException, MetamaskException, UnspecifiedErrorCode, TransactionException, } from '@injectivelabs/exceptions';
5
+ import { WalletAction, WalletDeviceType, BaseConcreteStrategy, } from '@injectivelabs/wallet-base';
6
+ import { toUtf8, TxGrpcApi } from '@injectivelabs/sdk-ts';
7
+ export class PrivateKeyWallet extends BaseConcreteStrategy {
8
+ privateKey;
9
+ constructor(args) {
10
+ super(args);
11
+ this.privateKey = args.privateKey
12
+ ? PrivateKeySigner.fromHex(args.privateKey)
13
+ : undefined;
14
+ }
15
+ async getWalletDeviceType() {
16
+ return Promise.resolve(WalletDeviceType.Other);
17
+ }
18
+ async enable() {
19
+ return Promise.resolve(true);
20
+ }
21
+ async disconnect() {
22
+ this.listeners = {};
23
+ }
24
+ async getAddresses() {
25
+ const pk = this.getPrivateKey();
26
+ try {
27
+ return Promise.resolve([pk.toAddress().toHex()]);
28
+ }
29
+ catch (e) {
30
+ throw new MetamaskException(new Error(e.message), {
31
+ code: UnspecifiedErrorCode,
32
+ type: ErrorType.WalletError,
33
+ contextModule: WalletAction.GetAccounts,
34
+ });
35
+ }
36
+ }
37
+ // eslint-disable-next-line class-methods-use-this
38
+ async getSessionOrConfirm(address) {
39
+ return Promise.resolve(`0x${Buffer.from(`Confirmation for ${address} at time: ${Date.now()}`).toString('hex')}`);
40
+ }
41
+ async sendEthereumTransaction(_transaction, _options) {
42
+ throw new WalletException(new Error('This wallet does not support sending Ethereum transactions'), {
43
+ code: UnspecifiedErrorCode,
44
+ type: ErrorType.WalletError,
45
+ contextModule: WalletAction.SendEthereumTransaction,
46
+ });
47
+ }
48
+ async sendTransaction(transaction, options) {
49
+ const { endpoints, txTimeout } = options;
50
+ if (!endpoints) {
51
+ throw new WalletException(new Error('You have to pass endpoints within the options for using Ethereum native wallets'));
52
+ }
53
+ const txApi = new TxGrpcApi(endpoints.grpc);
54
+ const response = await txApi.broadcast(transaction, { txTimeout });
55
+ if (response.code !== 0) {
56
+ throw new TransactionException(new Error(response.rawLog), {
57
+ code: UnspecifiedErrorCode,
58
+ contextCode: response.code,
59
+ contextModule: response.codespace,
60
+ });
61
+ }
62
+ return response;
63
+ }
64
+ async signEip712TypedData(eip712json, address) {
65
+ const pk = this.getPrivateKey();
66
+ if (getInjectiveSignerAddress(address) !== pk.toAddress().toBech32()) {
67
+ throw new WalletException(new Error('Signer address does not match the private key address'), {
68
+ code: UnspecifiedErrorCode,
69
+ type: ErrorType.WalletError,
70
+ contextModule: WalletAction.SignTransaction,
71
+ });
72
+ }
73
+ try {
74
+ const signature = await pk.signTypedData(JSON.parse(eip712json));
75
+ return `0x${Buffer.from(signature).toString('hex')}`;
76
+ }
77
+ catch (e) {
78
+ throw new MetamaskException(new Error(e.message), {
79
+ code: UnspecifiedErrorCode,
80
+ type: ErrorType.WalletError,
81
+ contextModule: WalletAction.SignTransaction,
82
+ });
83
+ }
84
+ }
85
+ async signAminoCosmosTransaction(_transaction) {
86
+ throw new WalletException(new Error('This wallet does not support signing Cosmos transactions'), {
87
+ code: UnspecifiedErrorCode,
88
+ type: ErrorType.WalletError,
89
+ contextModule: WalletAction.SignTransaction,
90
+ });
91
+ }
92
+ // eslint-disable-next-line class-methods-use-this
93
+ async signCosmosTransaction(_transaction) {
94
+ throw new WalletException(new Error('This wallet does not support signing Cosmos transactions'), {
95
+ code: UnspecifiedErrorCode,
96
+ type: ErrorType.WalletError,
97
+ contextModule: WalletAction.SignTransaction,
98
+ });
99
+ }
100
+ async signArbitrary(signer, data) {
101
+ const pk = this.getPrivateKey();
102
+ if (getInjectiveSignerAddress(signer) !== pk.toAddress().toBech32()) {
103
+ throw new WalletException(new Error('Signer address does not match the private key address'), {
104
+ code: UnspecifiedErrorCode,
105
+ type: ErrorType.WalletError,
106
+ contextModule: WalletAction.SignArbitrary,
107
+ });
108
+ }
109
+ try {
110
+ const signature = await pk.signHashed(Buffer.from(toUtf8(data), 'utf-8'));
111
+ return `0x${Buffer.from(signature).toString('base64')}`;
112
+ }
113
+ catch (e) {
114
+ throw new MetamaskException(new Error(e.message), {
115
+ code: UnspecifiedErrorCode,
116
+ type: ErrorType.WalletError,
117
+ contextModule: WalletAction.SignArbitrary,
118
+ });
119
+ }
120
+ }
121
+ async getEthereumChainId() {
122
+ try {
123
+ return Promise.resolve((this.chainId === ChainId.Mainnet
124
+ ? EthereumChainId.Mainnet
125
+ : EthereumChainId.Sepolia).toString(16));
126
+ }
127
+ catch (e) {
128
+ throw new MetamaskException(new Error(e.message), {
129
+ code: UnspecifiedErrorCode,
130
+ type: ErrorType.WalletError,
131
+ contextModule: WalletAction.GetChainId,
132
+ });
133
+ }
134
+ }
135
+ async getEthereumTransactionReceipt(_txHash) {
136
+ throw new WalletException(new Error('Not supported'));
137
+ }
138
+ // eslint-disable-next-line class-methods-use-this
139
+ async getPubKey() {
140
+ const pk = this.getPrivateKey();
141
+ return pk.toPublicKey().toBase64();
142
+ }
143
+ async onChainIdChanged(_callback) {
144
+ //
145
+ }
146
+ async onAccountChange(_callback) {
147
+ //
148
+ }
149
+ getPrivateKey() {
150
+ 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
+ });
156
+ }
157
+ return this.privateKey;
158
+ }
159
+ }
160
+ //# sourceMappingURL=strategy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"strategy.js","sourceRoot":"","sources":["../../../src/strategy/strategy.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,OAAO,EACL,OAAO,EAEP,eAAe,GAChB,MAAM,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abs/wallet-private-key",
3
+ "description": "Private key wallet strategy for use with @injectivelabs/wallet-core.",
4
+ "version": "0.0.2",
5
+ "sideEffects": false,
6
+ "author": {
7
+ "name": "InjectiveLabs",
8
+ "email": "admin@injectivelabs.org"
9
+ },
10
+ "license": "Apache-2.0",
11
+ "types": "dist/cjs/index.d.ts",
12
+ "main": "dist/cjs/index.js",
13
+ "module": "dist/esm/index.js",
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "_moduleAliases": {
18
+ "~wallet-private-key": "dist"
19
+ },
20
+ "scripts": {
21
+ "build": "tsc --build --force tsconfig.build.json && tsc --build --force tsconfig.build.esm.json && yarn build:post",
22
+ "build:watch": "tsc --build -w tsconfig.build.json && tsc -w --build tsconfig.build.esm.json && yarn build:post",
23
+ "build:post": "shx cp ../../../etc/stub/package.json.stub dist/cjs/package.json && shx cp ../../../etc/stub/package.esm.json.stub dist/esm/package.json",
24
+ "clean": "tsc --build tsconfig.build.json --clean && tsc --build tsconfig.build.esm.json --clean && shx rm -rf coverage *.log junit.xml dist && jest --clearCache && shx mkdir -p dist",
25
+ "test": "jest",
26
+ "test:watch": "jest --watch",
27
+ "test:ci": "jest --coverage --ci --reporters='jest-junit'",
28
+ "coverage": "jest --coverage",
29
+ "coverage:show": "live-server coverage",
30
+ "dev": "ts-node -r tsconfig-paths/register src/index.ts",
31
+ "start": "node dist/index.js"
32
+ },
33
+ "dependencies": {
34
+ "@injectivelabs/exceptions": "^1.14.14",
35
+ "@injectivelabs/sdk-ts": "^1.14.15",
36
+ "@injectivelabs/ts-types": "^1.14.14",
37
+ "@injectivelabs/utils": "^1.14.14",
38
+ "@injectivelabs/wallet-base": "^0.0.2"
39
+ },
40
+ "gitHead": "6442ae377bbfb3459d2fb3a44c650630a5b7f445",
41
+ "typedoc": {
42
+ "entryPoint": "./src/index.ts",
43
+ "readmeFile": "./README.md",
44
+ "displayName": "wallet-private-key API Documentation"
45
+ },
46
+ "resolutions": {
47
+ "**/libsodium": "npm:@bangjelkoski/noop",
48
+ "**/libsodium-wrappers": "npm:@bangjelkoski/noop"
49
+ }
50
+ }