@injectivelabs/wallet-private-key 1.14.57 → 1.15.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/package.json +6 -6
- package/dist/cjs/index.d.ts +0 -2
- package/dist/cjs/index.d.ts.map +0 -1
- package/dist/cjs/index.js +0 -6
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/package.json +0 -3
- package/dist/cjs/strategy/strategy.d.ts +0 -41
- package/dist/cjs/strategy/strategy.d.ts.map +0 -1
- package/dist/cjs/strategy/strategy.js +0 -164
- package/dist/cjs/strategy/strategy.js.map +0 -1
- package/dist/esm/index.d.ts +0 -2
- package/dist/esm/index.d.ts.map +0 -1
- package/dist/esm/index.js +0 -2
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/package.json +0 -3
- package/dist/esm/strategy/strategy.d.ts +0 -41
- package/dist/esm/strategy/strategy.d.ts.map +0 -1
- package/dist/esm/strategy/strategy.js +0 -160
- package/dist/esm/strategy/strategy.js.map +0 -1
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.
|
|
4
|
+
"version": "1.15.0",
|
|
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.
|
|
60
|
-
"@injectivelabs/sdk-ts": "^1.
|
|
61
|
-
"@injectivelabs/ts-types": "^1.
|
|
62
|
-
"@injectivelabs/wallet-base": "^1.
|
|
59
|
+
"@injectivelabs/exceptions": "^1.15.0",
|
|
60
|
+
"@injectivelabs/sdk-ts": "^1.15.0",
|
|
61
|
+
"@injectivelabs/ts-types": "^1.15.0",
|
|
62
|
+
"@injectivelabs/wallet-base": "^1.15.0"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "acae5b41a4c8a0ac4f137cce434b9db81800a1c5",
|
|
65
65
|
"typedoc": {
|
|
66
66
|
"entryPoint": "./src/index.ts",
|
|
67
67
|
"readmeFile": "./README.md",
|
package/dist/cjs/index.d.ts
DELETED
package/dist/cjs/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,IAAI,wBAAwB,EAAE,MAAM,wBAAwB,CAAA"}
|
package/dist/cjs/index.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PrivateKeyWalletStrategy = void 0;
|
|
4
|
-
var strategy_js_1 = require("./strategy/strategy.js");
|
|
5
|
-
Object.defineProperty(exports, "PrivateKeyWalletStrategy", { enumerable: true, get: function () { return strategy_js_1.PrivateKeyWallet; } });
|
|
6
|
-
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,sDAAqF;AAA5E,uHAAA,gBAAgB,OAA4B"}
|
package/dist/cjs/package.json
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
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 | string[]) => void): Promise<void>;
|
|
38
|
-
private getPrivateKey;
|
|
39
|
-
}
|
|
40
|
-
export {};
|
|
41
|
-
//# sourceMappingURL=strategy.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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,CAAC,OAAO,CAAC;IAInB,UAAU;IAIjB,YAAY,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAejC,mBAAmB,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC;IAQ7D,uBAAuB,CAC3B,YAAY,EAAE,OAAO,EACrB,QAAQ,EAAE;QAAE,OAAO,EAAE,cAAc,CAAC;QAAC,eAAe,EAAE,eAAe,CAAA;KAAE,GACtE,OAAO,CAAC,MAAM,CAAC;IAWZ,eAAe,CACnB,WAAW,EAAE,KAAK,EAClB,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,UAAU,CAAC;IAyBhB,mBAAmB,CACvB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,MAAM,CAAC;IA2BZ,0BAA0B,CAAC,YAAY,EAAE;QAC7C,OAAO,EAAE,MAAM,CAAA;QACf,OAAO,EAAE,UAAU,CAAA;KACpB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAYxB,qBAAqB,CAAC,YAAY,EAAE;QACxC,KAAK,EAAE,KAAK,CAAA;QACZ,aAAa,EAAE,MAAM,CAAA;QACrB,OAAO,EAAE,MAAM,CAAA;QACf,OAAO,EAAE,MAAM,CAAA;KAChB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAWzB,aAAa,CACjB,MAAM,EAAE,cAAc,EACtB,IAAI,EAAE,MAAM,GAAG,UAAU,GACxB,OAAO,CAAC,MAAM,CAAC;IA2BZ,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAiBrC,6BAA6B,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAK/D,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC;IAM5B,gBAAgB,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAInE,eAAe,CACnB,SAAS,EAAE,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM,EAAE,KAAK,IAAI,GACtD,OAAO,CAAC,IAAI,CAAC;IAIhB,OAAO,CAAC,aAAa;CActB"}
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PrivateKeyWallet = void 0;
|
|
4
|
-
/* eslint-disable class-methods-use-this */
|
|
5
|
-
const ts_types_1 = require("@injectivelabs/ts-types");
|
|
6
|
-
const sdk_ts_1 = require("@injectivelabs/sdk-ts");
|
|
7
|
-
const exceptions_1 = require("@injectivelabs/exceptions");
|
|
8
|
-
const wallet_base_1 = require("@injectivelabs/wallet-base");
|
|
9
|
-
const sdk_ts_2 = require("@injectivelabs/sdk-ts");
|
|
10
|
-
class PrivateKeyWallet extends wallet_base_1.BaseConcreteStrategy {
|
|
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
|
-
async getWalletDeviceType() {
|
|
19
|
-
return Promise.resolve(wallet_base_1.WalletDeviceType.Other);
|
|
20
|
-
}
|
|
21
|
-
async enable() {
|
|
22
|
-
return Promise.resolve(true);
|
|
23
|
-
}
|
|
24
|
-
async disconnect() {
|
|
25
|
-
this.listeners = {};
|
|
26
|
-
}
|
|
27
|
-
async getAddresses() {
|
|
28
|
-
const pk = this.getPrivateKey();
|
|
29
|
-
try {
|
|
30
|
-
return Promise.resolve([pk.toAddress().toHex()]);
|
|
31
|
-
}
|
|
32
|
-
catch (e) {
|
|
33
|
-
throw new exceptions_1.MetamaskException(new Error(e.message), {
|
|
34
|
-
code: exceptions_1.UnspecifiedErrorCode,
|
|
35
|
-
type: exceptions_1.ErrorType.WalletError,
|
|
36
|
-
contextModule: wallet_base_1.WalletAction.GetAccounts,
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
// eslint-disable-next-line class-methods-use-this
|
|
41
|
-
async getSessionOrConfirm(address) {
|
|
42
|
-
return Promise.resolve(`0x${Buffer.from(`Confirmation for ${address} at time: ${Date.now()}`).toString('hex')}`);
|
|
43
|
-
}
|
|
44
|
-
async sendEthereumTransaction(_transaction, _options) {
|
|
45
|
-
throw new exceptions_1.WalletException(new Error('This wallet does not support sending Ethereum transactions'), {
|
|
46
|
-
code: exceptions_1.UnspecifiedErrorCode,
|
|
47
|
-
type: exceptions_1.ErrorType.WalletError,
|
|
48
|
-
contextModule: wallet_base_1.WalletAction.SendEthereumTransaction,
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
async sendTransaction(transaction, options) {
|
|
52
|
-
const { endpoints, txTimeout } = options;
|
|
53
|
-
if (!endpoints) {
|
|
54
|
-
throw new exceptions_1.WalletException(new Error('You have to pass endpoints within the options for using Ethereum native wallets'));
|
|
55
|
-
}
|
|
56
|
-
const txApi = new sdk_ts_2.TxGrpcApi(endpoints.grpc);
|
|
57
|
-
const response = await txApi.broadcast(transaction, { txTimeout });
|
|
58
|
-
if (response.code !== 0) {
|
|
59
|
-
throw new exceptions_1.TransactionException(new Error(response.rawLog), {
|
|
60
|
-
code: exceptions_1.UnspecifiedErrorCode,
|
|
61
|
-
contextCode: response.code,
|
|
62
|
-
contextModule: response.codespace,
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
return response;
|
|
66
|
-
}
|
|
67
|
-
async signEip712TypedData(eip712json, address) {
|
|
68
|
-
const pk = this.getPrivateKey();
|
|
69
|
-
if ((0, sdk_ts_1.getInjectiveSignerAddress)(address) !== pk.toAddress().toBech32()) {
|
|
70
|
-
throw new exceptions_1.WalletException(new Error('Signer address does not match the private key address'), {
|
|
71
|
-
code: exceptions_1.UnspecifiedErrorCode,
|
|
72
|
-
type: exceptions_1.ErrorType.WalletError,
|
|
73
|
-
contextModule: wallet_base_1.WalletAction.SignTransaction,
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
try {
|
|
77
|
-
const signature = await pk.signTypedData(JSON.parse(eip712json));
|
|
78
|
-
return `0x${Buffer.from(signature).toString('hex')}`;
|
|
79
|
-
}
|
|
80
|
-
catch (e) {
|
|
81
|
-
throw new exceptions_1.MetamaskException(new Error(e.message), {
|
|
82
|
-
code: exceptions_1.UnspecifiedErrorCode,
|
|
83
|
-
type: exceptions_1.ErrorType.WalletError,
|
|
84
|
-
contextModule: wallet_base_1.WalletAction.SignTransaction,
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
async signAminoCosmosTransaction(_transaction) {
|
|
89
|
-
throw new exceptions_1.WalletException(new Error('This wallet does not support signing Cosmos transactions'), {
|
|
90
|
-
code: exceptions_1.UnspecifiedErrorCode,
|
|
91
|
-
type: exceptions_1.ErrorType.WalletError,
|
|
92
|
-
contextModule: wallet_base_1.WalletAction.SignTransaction,
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
// eslint-disable-next-line class-methods-use-this
|
|
96
|
-
async signCosmosTransaction(_transaction) {
|
|
97
|
-
throw new exceptions_1.WalletException(new Error('This wallet does not support signing Cosmos transactions'), {
|
|
98
|
-
code: exceptions_1.UnspecifiedErrorCode,
|
|
99
|
-
type: exceptions_1.ErrorType.WalletError,
|
|
100
|
-
contextModule: wallet_base_1.WalletAction.SignTransaction,
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
async signArbitrary(signer, data) {
|
|
104
|
-
const pk = this.getPrivateKey();
|
|
105
|
-
if ((0, sdk_ts_1.getInjectiveSignerAddress)(signer) !== pk.toAddress().toBech32()) {
|
|
106
|
-
throw new exceptions_1.WalletException(new Error('Signer address does not match the private key address'), {
|
|
107
|
-
code: exceptions_1.UnspecifiedErrorCode,
|
|
108
|
-
type: exceptions_1.ErrorType.WalletError,
|
|
109
|
-
contextModule: wallet_base_1.WalletAction.SignArbitrary,
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
try {
|
|
113
|
-
const signature = await pk.signHashed(Buffer.from((0, sdk_ts_2.toUtf8)(data), 'utf-8'));
|
|
114
|
-
return `0x${Buffer.from(signature).toString('base64')}`;
|
|
115
|
-
}
|
|
116
|
-
catch (e) {
|
|
117
|
-
throw new exceptions_1.MetamaskException(new Error(e.message), {
|
|
118
|
-
code: exceptions_1.UnspecifiedErrorCode,
|
|
119
|
-
type: exceptions_1.ErrorType.WalletError,
|
|
120
|
-
contextModule: wallet_base_1.WalletAction.SignArbitrary,
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
async getEthereumChainId() {
|
|
125
|
-
try {
|
|
126
|
-
return Promise.resolve((this.chainId === ts_types_1.ChainId.Mainnet
|
|
127
|
-
? ts_types_1.EthereumChainId.Mainnet
|
|
128
|
-
: ts_types_1.EthereumChainId.Sepolia).toString(16));
|
|
129
|
-
}
|
|
130
|
-
catch (e) {
|
|
131
|
-
throw new exceptions_1.MetamaskException(new Error(e.message), {
|
|
132
|
-
code: exceptions_1.UnspecifiedErrorCode,
|
|
133
|
-
type: exceptions_1.ErrorType.WalletError,
|
|
134
|
-
contextModule: wallet_base_1.WalletAction.GetChainId,
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
async getEthereumTransactionReceipt(_txHash) {
|
|
139
|
-
throw new exceptions_1.WalletException(new Error('Not supported'));
|
|
140
|
-
}
|
|
141
|
-
// eslint-disable-next-line class-methods-use-this
|
|
142
|
-
async getPubKey() {
|
|
143
|
-
const pk = this.getPrivateKey();
|
|
144
|
-
return pk.toPublicKey().toBase64();
|
|
145
|
-
}
|
|
146
|
-
async onChainIdChanged(_callback) {
|
|
147
|
-
//
|
|
148
|
-
}
|
|
149
|
-
async onAccountChange(_callback) {
|
|
150
|
-
//
|
|
151
|
-
}
|
|
152
|
-
getPrivateKey() {
|
|
153
|
-
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
|
-
});
|
|
159
|
-
}
|
|
160
|
-
return this.privateKey;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
exports.PrivateKeyWallet = PrivateKeyWallet;
|
|
164
|
-
//# sourceMappingURL=strategy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"strategy.js","sourceRoot":"","sources":["../../../src/strategy/strategy.ts"],"names":[],"mappings":";;;AAAA,2CAA2C;AAC3C,sDAIgC;AAChC,kDAK8B;AAC9B,0DAMkC;AAClC,4DAQ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CAAC,OAAO,CAAC,EAAE;gBACzD,IAAI,EAAE,iCAAoB;gBAC1B,IAAI,EAAE,sBAAS,CAAC,WAAW;gBAC3B,aAAa,EAAE,0BAAY,CAAC,UAAU;aACvC,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;IAED,KAAK,CAAC,6BAA6B,CAAC,OAAe;QACjD,MAAM,IAAI,4BAAe,CAAC,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC,CAAA;IACvD,CAAC;IAED,kDAAkD;IAClD,KAAK,CAAC,SAAS;QACb,MAAM,EAAE,GAAG,IAAI,CAAC,aAAa,EAAE,CAAA;QAE/B,OAAO,EAAE,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE,CAAA;IACpC,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,SAAkC;QACvD,EAAE;IACJ,CAAC;IAED,KAAK,CAAC,eAAe,CACnB,SAAuD;QAEvD,EAAE;IACJ,CAAC;IAEO,aAAa;QACnB,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACrB,MAAM,IAAI,4BAAe,CACvB,IAAI,KAAK,CAAC,+CAA+C,CAAC,EAC1D;gBACE,IAAI,EAAE,iCAAoB;gBAC1B,IAAI,EAAE,sBAAS,CAAC,uBAAuB;gBACvC,aAAa,EAAE,0BAAY,CAAC,WAAW;aACxC,CACF,CAAA;QACH,CAAC;QAED,OAAO,IAAI,CAAC,UAAU,CAAA;IACxB,CAAC;CACF;AA1OD,4CA0OC"}
|
package/dist/esm/index.d.ts
DELETED
package/dist/esm/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,IAAI,wBAAwB,EAAE,MAAM,wBAAwB,CAAA"}
|
package/dist/esm/index.js
DELETED
package/dist/esm/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,IAAI,wBAAwB,EAAE,MAAM,wBAAwB,CAAA"}
|
package/dist/esm/package.json
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
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 | string[]) => void): Promise<void>;
|
|
38
|
-
private getPrivateKey;
|
|
39
|
-
}
|
|
40
|
-
export {};
|
|
41
|
-
//# sourceMappingURL=strategy.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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,CAAC,OAAO,CAAC;IAInB,UAAU;IAIjB,YAAY,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IA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AAC,aAAa;CActB"}
|
|
@@ -1,160 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"strategy.js","sourceRoot":"","sources":["../../../src/strategy/strategy.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,OAAO,EACL,OAAO,EAEP,eAAe,GAChB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAGL,UAAU,IAAI,gBAAgB,EAC9B,yBAAyB,GAC1B,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EACL,SAAS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