@dydxprotocol/v4-client-js 2.7.0 → 2.8.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/CHANGELOG.md +2 -2
- package/build/cjs/src/clients/modules/local-wallet.js +12 -1
- package/build/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/build/esm/src/clients/modules/local-wallet.d.ts +2 -0
- package/build/esm/src/clients/modules/local-wallet.d.ts.map +1 -1
- package/build/esm/src/clients/modules/local-wallet.js +13 -2
- package/build/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/clients/modules/local-wallet.ts +14 -0
package/package.json
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Secp256k1Pubkey, StdFee, encodeSecp256k1Pubkey } from '@cosmjs/amino';
|
|
2
|
+
import { fromHex } from '@cosmjs/encoding';
|
|
2
3
|
import {
|
|
3
4
|
AccountData,
|
|
4
5
|
DirectSecp256k1HdWallet,
|
|
6
|
+
DirectSecp256k1Wallet,
|
|
5
7
|
EncodeObject,
|
|
6
8
|
OfflineSigner,
|
|
7
9
|
} from '@cosmjs/proto-signing';
|
|
@@ -9,6 +11,7 @@ import { SigningStargateClient } from '@cosmjs/stargate';
|
|
|
9
11
|
import Long from 'long';
|
|
10
12
|
import protobuf from 'protobufjs';
|
|
11
13
|
|
|
14
|
+
import { stripHexPrefix } from '../../lib/helpers';
|
|
12
15
|
import { generateRegistry } from '../lib/registry';
|
|
13
16
|
import { TransactionOptions } from '../types';
|
|
14
17
|
import { TransactionSigner } from './signer';
|
|
@@ -36,6 +39,12 @@ export default class LocalWallet {
|
|
|
36
39
|
return wallet;
|
|
37
40
|
}
|
|
38
41
|
|
|
42
|
+
static async fromPrivateKey(pkHex: string, prefix?: string): Promise<LocalWallet> {
|
|
43
|
+
const wallet = new LocalWallet();
|
|
44
|
+
await wallet.setPrivateKey(pkHex, prefix);
|
|
45
|
+
return wallet;
|
|
46
|
+
}
|
|
47
|
+
|
|
39
48
|
async setSigner(signer: OfflineSigner): Promise<void> {
|
|
40
49
|
this.offlineSigner = signer;
|
|
41
50
|
const stargateClient = await SigningStargateClient.offline(signer, {
|
|
@@ -54,6 +63,11 @@ export default class LocalWallet {
|
|
|
54
63
|
return this.setSigner(signer);
|
|
55
64
|
}
|
|
56
65
|
|
|
66
|
+
async setPrivateKey(pkHex: string, prefix?: string): Promise<void> {
|
|
67
|
+
const signer = await DirectSecp256k1Wallet.fromKey(fromHex(stripHexPrefix(pkHex)), prefix);
|
|
68
|
+
return this.setSigner(signer);
|
|
69
|
+
}
|
|
70
|
+
|
|
57
71
|
public async signTransaction(
|
|
58
72
|
messages: EncodeObject[],
|
|
59
73
|
transactionOptions: TransactionOptions,
|