@injectivelabs/wallet-private-key 1.16.38-alpha.2 → 1.16.38-alpha.4
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/dist/cjs/index.cjs +17 -8
- package/dist/cjs/index.d.cts +7 -1
- package/dist/esm/index.d.ts +7 -1
- package/dist/esm/index.js +10 -1
- package/package.json +5 -5
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
let __injectivelabs_sdk_ts = require("@injectivelabs/sdk-ts");
|
|
2
1
|
let __injectivelabs_ts_types = require("@injectivelabs/ts-types");
|
|
2
|
+
let __injectivelabs_sdk_ts_core_accounts = require("@injectivelabs/sdk-ts/core/accounts");
|
|
3
|
+
let __injectivelabs_sdk_ts_core_tx = require("@injectivelabs/sdk-ts/core/tx");
|
|
3
4
|
let __injectivelabs_wallet_base = require("@injectivelabs/wallet-base");
|
|
5
|
+
let __injectivelabs_sdk_ts_utils = require("@injectivelabs/sdk-ts/utils");
|
|
4
6
|
let __injectivelabs_exceptions = require("@injectivelabs/exceptions");
|
|
5
7
|
|
|
6
8
|
//#region \0@oxc-project+runtime@0.98.0/helpers/typeof.js
|
|
@@ -72,8 +74,15 @@ var PrivateKeyWallet = class extends __injectivelabs_wallet_base.BaseConcreteStr
|
|
|
72
74
|
});
|
|
73
75
|
}
|
|
74
76
|
}
|
|
77
|
+
async getAddressesInfo() {
|
|
78
|
+
throw new __injectivelabs_exceptions.WalletException(/* @__PURE__ */ new Error("getAddressesInfo is not implemented"), {
|
|
79
|
+
code: __injectivelabs_exceptions.UnspecifiedErrorCode,
|
|
80
|
+
type: __injectivelabs_exceptions.ErrorType.WalletError,
|
|
81
|
+
contextModule: __injectivelabs_wallet_base.WalletAction.GetAccounts
|
|
82
|
+
});
|
|
83
|
+
}
|
|
75
84
|
async getSessionOrConfirm(address) {
|
|
76
|
-
return Promise.resolve(`0x${(0,
|
|
85
|
+
return Promise.resolve(`0x${(0, __injectivelabs_sdk_ts_utils.uint8ArrayToHex)((0, __injectivelabs_sdk_ts_utils.stringToUint8Array)(`Confirmation for ${address} at time: ${Date.now()}`))}`);
|
|
77
86
|
}
|
|
78
87
|
async sendEvmTransaction(_transaction, _options) {
|
|
79
88
|
throw new __injectivelabs_exceptions.WalletException(/* @__PURE__ */ new Error("This wallet does not support sending Evm transactions"), {
|
|
@@ -85,7 +94,7 @@ var PrivateKeyWallet = class extends __injectivelabs_wallet_base.BaseConcreteStr
|
|
|
85
94
|
async sendTransaction(transaction, options) {
|
|
86
95
|
const { endpoints, txTimeout } = options;
|
|
87
96
|
if (!endpoints) throw new __injectivelabs_exceptions.WalletException(/* @__PURE__ */ new Error("You have to pass endpoints within the options for using Ethereum native wallets"));
|
|
88
|
-
const response = await new
|
|
97
|
+
const response = await new __injectivelabs_sdk_ts_core_tx.TxGrpcApi(endpoints.grpc).broadcast(transaction, { txTimeout });
|
|
89
98
|
if (response.code !== 0) throw new __injectivelabs_exceptions.TransactionException(new Error(response.rawLog), {
|
|
90
99
|
code: __injectivelabs_exceptions.UnspecifiedErrorCode,
|
|
91
100
|
contextCode: response.code,
|
|
@@ -95,13 +104,13 @@ var PrivateKeyWallet = class extends __injectivelabs_wallet_base.BaseConcreteStr
|
|
|
95
104
|
}
|
|
96
105
|
async signEip712TypedData(eip712json, address) {
|
|
97
106
|
const pk = this.getPrivateKey();
|
|
98
|
-
if ((0,
|
|
107
|
+
if ((0, __injectivelabs_sdk_ts_core_tx.getInjectiveSignerAddress)(address) !== pk.toAddress().toBech32()) throw new __injectivelabs_exceptions.WalletException(/* @__PURE__ */ new Error("Signer address does not match the private key address"), {
|
|
99
108
|
code: __injectivelabs_exceptions.UnspecifiedErrorCode,
|
|
100
109
|
type: __injectivelabs_exceptions.ErrorType.WalletError,
|
|
101
110
|
contextModule: __injectivelabs_wallet_base.WalletAction.SignTransaction
|
|
102
111
|
});
|
|
103
112
|
try {
|
|
104
|
-
return `0x${(0,
|
|
113
|
+
return `0x${(0, __injectivelabs_sdk_ts_utils.uint8ArrayToHex)(await pk.signTypedData(JSON.parse(eip712json)))}`;
|
|
105
114
|
} catch (e) {
|
|
106
115
|
throw new __injectivelabs_exceptions.MetamaskException(new Error(e.message), {
|
|
107
116
|
code: __injectivelabs_exceptions.UnspecifiedErrorCode,
|
|
@@ -126,13 +135,13 @@ var PrivateKeyWallet = class extends __injectivelabs_wallet_base.BaseConcreteStr
|
|
|
126
135
|
}
|
|
127
136
|
async signArbitrary(signer, data) {
|
|
128
137
|
const pk = this.getPrivateKey();
|
|
129
|
-
if ((0,
|
|
138
|
+
if ((0, __injectivelabs_sdk_ts_core_tx.getInjectiveSignerAddress)(signer) !== pk.toAddress().toBech32()) throw new __injectivelabs_exceptions.WalletException(/* @__PURE__ */ new Error("Signer address does not match the private key address"), {
|
|
130
139
|
code: __injectivelabs_exceptions.UnspecifiedErrorCode,
|
|
131
140
|
type: __injectivelabs_exceptions.ErrorType.WalletError,
|
|
132
141
|
contextModule: __injectivelabs_wallet_base.WalletAction.SignArbitrary
|
|
133
142
|
});
|
|
134
143
|
try {
|
|
135
|
-
return `0x${(0,
|
|
144
|
+
return `0x${(0, __injectivelabs_sdk_ts_utils.uint8ArrayToBase64)(await pk.signHashed((0, __injectivelabs_sdk_ts_utils.stringToUint8Array)((0, __injectivelabs_sdk_ts_utils.toUtf8)(data))))}`;
|
|
136
145
|
} catch (e) {
|
|
137
146
|
throw new __injectivelabs_exceptions.MetamaskException(new Error(e.message), {
|
|
138
147
|
code: __injectivelabs_exceptions.UnspecifiedErrorCode,
|
|
@@ -168,7 +177,7 @@ var PrivateKeyWallet = class extends __injectivelabs_wallet_base.BaseConcreteStr
|
|
|
168
177
|
type: __injectivelabs_exceptions.ErrorType.WalletNotInstalledError,
|
|
169
178
|
contextModule: __injectivelabs_wallet_base.WalletAction.GetAccounts
|
|
170
179
|
});
|
|
171
|
-
this.privateKey =
|
|
180
|
+
this.privateKey = __injectivelabs_sdk_ts_core_accounts.PrivateKey.fromHex(this.metadata.privateKey.privateKey);
|
|
172
181
|
}
|
|
173
182
|
return this.privateKey;
|
|
174
183
|
}
|
package/dist/cjs/index.d.cts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AccountAddress, EvmChainId } from "@injectivelabs/ts-types";
|
|
2
2
|
import { BaseConcreteStrategy, ConcreteWalletStrategy, SendTransactionOptions, StdSignDoc, WalletDeviceType } from "@injectivelabs/wallet-base";
|
|
3
|
-
import {
|
|
3
|
+
import { TxResponse } from "@injectivelabs/sdk-ts/core/tx";
|
|
4
|
+
import { AminoSignResponse, DirectSignResponse, TxRaw } from "@injectivelabs/sdk-ts/types";
|
|
4
5
|
|
|
5
6
|
//#region src/strategy/strategy.d.ts
|
|
6
7
|
declare class PrivateKeyWallet extends BaseConcreteStrategy implements ConcreteWalletStrategy {
|
|
@@ -9,6 +10,11 @@ declare class PrivateKeyWallet extends BaseConcreteStrategy implements ConcreteW
|
|
|
9
10
|
enable(): Promise<boolean>;
|
|
10
11
|
disconnect(): Promise<void>;
|
|
11
12
|
getAddresses(): Promise<string[]>;
|
|
13
|
+
getAddressesInfo(): Promise<{
|
|
14
|
+
address: string;
|
|
15
|
+
derivationPath: string;
|
|
16
|
+
baseDerivationPath: string;
|
|
17
|
+
}[]>;
|
|
12
18
|
getSessionOrConfirm(address: AccountAddress): Promise<string>;
|
|
13
19
|
sendEvmTransaction(_transaction: unknown, _options: {
|
|
14
20
|
address: AccountAddress;
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { AminoSignResponse, DirectSignResponse, TxRaw, TxResponse } from "@injectivelabs/sdk-ts";
|
|
2
1
|
import { AccountAddress, EvmChainId } from "@injectivelabs/ts-types";
|
|
2
|
+
import { TxResponse } from "@injectivelabs/sdk-ts/core/tx";
|
|
3
3
|
import { BaseConcreteStrategy, ConcreteWalletStrategy, SendTransactionOptions, StdSignDoc, WalletDeviceType } from "@injectivelabs/wallet-base";
|
|
4
|
+
import { AminoSignResponse, DirectSignResponse, TxRaw } from "@injectivelabs/sdk-ts/types";
|
|
4
5
|
|
|
5
6
|
//#region src/strategy/strategy.d.ts
|
|
6
7
|
declare class PrivateKeyWallet extends BaseConcreteStrategy implements ConcreteWalletStrategy {
|
|
@@ -9,6 +10,11 @@ declare class PrivateKeyWallet extends BaseConcreteStrategy implements ConcreteW
|
|
|
9
10
|
enable(): Promise<boolean>;
|
|
10
11
|
disconnect(): Promise<void>;
|
|
11
12
|
getAddresses(): Promise<string[]>;
|
|
13
|
+
getAddressesInfo(): Promise<{
|
|
14
|
+
address: string;
|
|
15
|
+
derivationPath: string;
|
|
16
|
+
baseDerivationPath: string;
|
|
17
|
+
}[]>;
|
|
12
18
|
getSessionOrConfirm(address: AccountAddress): Promise<string>;
|
|
13
19
|
sendEvmTransaction(_transaction: unknown, _options: {
|
|
14
20
|
address: AccountAddress;
|
package/dist/esm/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { PrivateKey, TxGrpcApi, getInjectiveSignerAddress, stringToUint8Array, toUtf8, uint8ArrayToBase64, uint8ArrayToHex } from "@injectivelabs/sdk-ts";
|
|
2
1
|
import { ChainId, EvmChainId } from "@injectivelabs/ts-types";
|
|
2
|
+
import { PrivateKey } from "@injectivelabs/sdk-ts/core/accounts";
|
|
3
|
+
import { TxGrpcApi, getInjectiveSignerAddress } from "@injectivelabs/sdk-ts/core/tx";
|
|
3
4
|
import { BaseConcreteStrategy, WalletAction, WalletDeviceType } from "@injectivelabs/wallet-base";
|
|
5
|
+
import { stringToUint8Array, toUtf8, uint8ArrayToBase64, uint8ArrayToHex } from "@injectivelabs/sdk-ts/utils";
|
|
4
6
|
import { ErrorType, MetamaskException, TransactionException, UnspecifiedErrorCode, WalletException } from "@injectivelabs/exceptions";
|
|
5
7
|
|
|
6
8
|
//#region \0@oxc-project+runtime@0.98.0/helpers/typeof.js
|
|
@@ -72,6 +74,13 @@ var PrivateKeyWallet = class extends BaseConcreteStrategy {
|
|
|
72
74
|
});
|
|
73
75
|
}
|
|
74
76
|
}
|
|
77
|
+
async getAddressesInfo() {
|
|
78
|
+
throw new WalletException(/* @__PURE__ */ new Error("getAddressesInfo is not implemented"), {
|
|
79
|
+
code: UnspecifiedErrorCode,
|
|
80
|
+
type: ErrorType.WalletError,
|
|
81
|
+
contextModule: WalletAction.GetAccounts
|
|
82
|
+
});
|
|
83
|
+
}
|
|
75
84
|
async getSessionOrConfirm(address) {
|
|
76
85
|
return Promise.resolve(`0x${uint8ArrayToHex(stringToUint8Array(`Confirmation for ${address} at time: ${Date.now()}`))}`);
|
|
77
86
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@injectivelabs/wallet-private-key",
|
|
3
|
-
"version": "1.16.38-alpha.
|
|
3
|
+
"version": "1.16.38-alpha.4",
|
|
4
4
|
"description": "Private key wallet strategy for use with @injectivelabs/wallet-core.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
@@ -38,10 +38,10 @@
|
|
|
38
38
|
"dist"
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@injectivelabs/exceptions": "1.16.38-alpha.
|
|
42
|
-
"@injectivelabs/
|
|
43
|
-
"@injectivelabs/
|
|
44
|
-
"@injectivelabs/
|
|
41
|
+
"@injectivelabs/exceptions": "1.16.38-alpha.3",
|
|
42
|
+
"@injectivelabs/ts-types": "1.16.38-alpha.2",
|
|
43
|
+
"@injectivelabs/wallet-base": "1.16.38-alpha.4",
|
|
44
|
+
"@injectivelabs/sdk-ts": "1.16.38-alpha.4"
|
|
45
45
|
},
|
|
46
46
|
"publishConfig": {
|
|
47
47
|
"access": "public"
|