@injectivelabs/sdk-ts 1.14.13-beta.1 → 1.14.13-beta.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/dist/cjs/core/accounts/PrivateKey.d.ts +7 -7
- package/dist/cjs/core/accounts/PrivateKey.d.ts.map +1 -1
- package/dist/cjs/core/accounts/PrivateKey.js +43 -65
- package/dist/cjs/core/accounts/PrivateKey.js.map +1 -1
- package/dist/esm/core/accounts/PrivateKey.d.ts +7 -7
- package/dist/esm/core/accounts/PrivateKey.d.ts.map +1 -1
- package/dist/esm/core/accounts/PrivateKey.js +11 -12
- package/dist/esm/core/accounts/PrivateKey.js.map +1 -1
- package/package.json +3 -3
|
@@ -25,7 +25,7 @@ export declare class PrivateKey {
|
|
|
25
25
|
* @param {string|undefined} path the HD path that follows the BIP32 standard (optional)
|
|
26
26
|
* @returns {PrivateKey} Initialized PrivateKey object
|
|
27
27
|
*/
|
|
28
|
-
static fromMnemonic(words: string
|
|
28
|
+
static fromMnemonic(words: string): PrivateKey;
|
|
29
29
|
/**
|
|
30
30
|
* Create a PrivateKey instance from a given private key and a HD derivation path.
|
|
31
31
|
* If path is not given, default to Band's HD prefix 494 and all other indexes being zeroes.
|
|
@@ -72,37 +72,37 @@ export declare class PrivateKey {
|
|
|
72
72
|
* @param {string} messageBytes: the message that will be hashed and signed, a Buffer made of bytes
|
|
73
73
|
* @returns {Uint8Array} a signature of this private key over the given message
|
|
74
74
|
*/
|
|
75
|
-
sign(messageBytes: Buffer):
|
|
75
|
+
sign(messageBytes: Buffer): Uint8Array;
|
|
76
76
|
/**
|
|
77
77
|
* Sign the given message using the edcsa sign_deterministic function.
|
|
78
78
|
* @param {Buffer} messageBytes: the message that will be hashed and signed, a Buffer made of bytes
|
|
79
79
|
* @returns {Uint8Array} a signature of this private key over the given message
|
|
80
80
|
*/
|
|
81
|
-
signEcda(messageBytes: Buffer):
|
|
81
|
+
signEcda(messageBytes: Buffer): Uint8Array;
|
|
82
82
|
/**
|
|
83
83
|
* Sign the given message using the wallet's _signingKey function.
|
|
84
84
|
* @param {string} messageHashedBytes: the message that will be signed, a Buffer made of bytes
|
|
85
85
|
* @returns {Uint8Array} a signature of this private key over the given message
|
|
86
86
|
*/
|
|
87
|
-
signHashed(messageHashedBytes: Buffer):
|
|
87
|
+
signHashed(messageHashedBytes: Buffer): Uint8Array;
|
|
88
88
|
/**
|
|
89
89
|
* Sign the given message using the edcsa sign_deterministic function.
|
|
90
90
|
* @param {Buffer} messageHashedBytes: the message that will be signed, a Buffer made of bytes
|
|
91
91
|
* @returns {Uint8Array} a signature of this private key over the given message
|
|
92
92
|
*/
|
|
93
|
-
signHashedEcda(messageHashedBytes: Buffer):
|
|
93
|
+
signHashedEcda(messageHashedBytes: Buffer): Uint8Array;
|
|
94
94
|
/**
|
|
95
95
|
* Sign the given typed data using the edcsa sign_deterministic function.
|
|
96
96
|
* @param {Buffer} eip712Data: the typed data that will be hashed and signed, a Buffer made of bytes
|
|
97
97
|
* @returns {Uint8Array} a signature of this private key over the given message
|
|
98
98
|
*/
|
|
99
|
-
signTypedData(eip712Data: any):
|
|
99
|
+
signTypedData(eip712Data: any): Uint8Array;
|
|
100
100
|
/**
|
|
101
101
|
* Sign the given typed data using the edcsa sign_deterministic function.
|
|
102
102
|
* @param {Buffer} eip712Data: the typed data that will be signed, a Buffer made of bytes
|
|
103
103
|
* @returns {Uint8Array} a signature of this private key over the given message
|
|
104
104
|
*/
|
|
105
|
-
signHashedTypedData(eip712Data: Buffer):
|
|
105
|
+
signHashedTypedData(eip712Data: Buffer): Uint8Array;
|
|
106
106
|
/**
|
|
107
107
|
* Verify signature using EIP712 typed data
|
|
108
108
|
* and the publicKey
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrivateKey.d.ts","sourceRoot":"","sources":["../../../../src/core/accounts/PrivateKey.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"PrivateKey.d.ts","sourceRoot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;;;;;;;SASK;WACS,eAAe,CAAC,EAC5B,SAAS,EACT,MAAM,EACN,SAAS,GACV,EAAE;QACD,SAAS,EAAE,MAAM,CAAA;QACjB,MAAM,EAAE,GAAG,CAAA;QACX,SAAS,EAAE,MAAM,CAAA;KAClB,GAAG,OAAO;IAqBX;;;;;;;;;SASK;IACE,qBAAqB,CAAC,EAC3B,SAAS,EACT,MAAM,GACP,EAAE;QACD,SAAS,EAAE,MAAM,CAAA;QACjB,MAAM,EAAE,GAAG,CAAA;KACZ,GAAG,OAAO;IAkBX;;;;;;;;;QASI;WACU,qBAAqB,CAAC,EAClC,KAAK,EACL,MAAM,GACP,EAAE;QACD,KAAK,EAAE,iBAAiB,CAAC,KAAK,CAAA;QAC9B,MAAM,EAAE;YACN,aAAa,EAAE,MAAM,GAAG,MAAM,CAAA;YAC9B,SAAS,EAAE,MAAM,CAAA;SAClB,CAAA;KACF,GAAG,OAAO;IA+EX;;;;;;;;;SASK;WACS,wBAAwB,CAAC,EACrC,SAAS,EACT,OAAO,EACP,SAAS,GACV,EAAE;QACD,SAAS,EAAE,MAAM,CAAA;QACjB,OAAO,EAAE,MAAM,CAAA;QACf,SAAS,EAAE,MAAM,CAAA;KAClB,GAAG,OAAO;CAOZ"}
|
|
@@ -22,15 +22,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
27
|
};
|
|
@@ -40,7 +31,6 @@ const bip39_1 = require("bip39");
|
|
|
40
31
|
const ethers_1 = require("ethers");
|
|
41
32
|
const secp256k1_1 = __importDefault(require("secp256k1"));
|
|
42
33
|
const keccak256_1 = __importDefault(require("keccak256"));
|
|
43
|
-
const constants_1 = require("../../utils/constants");
|
|
44
34
|
const PublicKey_1 = require("./PublicKey");
|
|
45
35
|
const Address_1 = require("./Address");
|
|
46
36
|
const BytesUtils = __importStar(require("@ethersproject/bytes"));
|
|
@@ -79,8 +69,8 @@ class PrivateKey {
|
|
|
79
69
|
* @param {string|undefined} path the HD path that follows the BIP32 standard (optional)
|
|
80
70
|
* @returns {PrivateKey} Initialized PrivateKey object
|
|
81
71
|
*/
|
|
82
|
-
static fromMnemonic(words
|
|
83
|
-
return new PrivateKey(ethers_1.Wallet.
|
|
72
|
+
static fromMnemonic(words) {
|
|
73
|
+
return new PrivateKey(new ethers_1.Wallet(ethers_1.Wallet.fromPhrase(words).signingKey));
|
|
84
74
|
}
|
|
85
75
|
/**
|
|
86
76
|
* Create a PrivateKey instance from a given private key and a HD derivation path.
|
|
@@ -105,7 +95,7 @@ class PrivateKey {
|
|
|
105
95
|
const privateKeyBuff = isString
|
|
106
96
|
? Buffer.from(privateKeyHex.toString(), 'hex')
|
|
107
97
|
: privateKey;
|
|
108
|
-
return new PrivateKey(new ethers_1.Wallet(privateKeyBuff));
|
|
98
|
+
return new PrivateKey(new ethers_1.Wallet(Buffer.from(privateKeyBuff).toString('hex')));
|
|
109
99
|
}
|
|
110
100
|
/**
|
|
111
101
|
* Return the private key in hex
|
|
@@ -152,13 +142,11 @@ class PrivateKey {
|
|
|
152
142
|
* @returns {Uint8Array} a signature of this private key over the given message
|
|
153
143
|
*/
|
|
154
144
|
sign(messageBytes) {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
return BytesUtils.arrayify(BytesUtils.concat([splitSignature.r, splitSignature.s]));
|
|
161
|
-
});
|
|
145
|
+
const { wallet } = this;
|
|
146
|
+
const msgHash = (0, keccak256_1.default)(messageBytes);
|
|
147
|
+
const signature = wallet.signingKey.sign(msgHash);
|
|
148
|
+
const splitSignature = BytesUtils.splitSignature(signature);
|
|
149
|
+
return BytesUtils.arrayify(BytesUtils.concat([splitSignature.r, splitSignature.s]));
|
|
162
150
|
}
|
|
163
151
|
/**
|
|
164
152
|
* Sign the given message using the edcsa sign_deterministic function.
|
|
@@ -166,16 +154,14 @@ class PrivateKey {
|
|
|
166
154
|
* @returns {Uint8Array} a signature of this private key over the given message
|
|
167
155
|
*/
|
|
168
156
|
signEcda(messageBytes) {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
return signature;
|
|
178
|
-
});
|
|
157
|
+
const { wallet } = this;
|
|
158
|
+
const msgHash = (0, keccak256_1.default)(messageBytes);
|
|
159
|
+
const privateKeyHex = wallet.privateKey.startsWith('0x')
|
|
160
|
+
? wallet.privateKey.slice(2)
|
|
161
|
+
: wallet.privateKey;
|
|
162
|
+
const privateKey = Uint8Array.from(Buffer.from(privateKeyHex, 'hex'));
|
|
163
|
+
const { signature } = secp256k1_1.default.ecdsaSign(msgHash, privateKey);
|
|
164
|
+
return signature;
|
|
179
165
|
}
|
|
180
166
|
/**
|
|
181
167
|
* Sign the given message using the wallet's _signingKey function.
|
|
@@ -183,12 +169,10 @@ class PrivateKey {
|
|
|
183
169
|
* @returns {Uint8Array} a signature of this private key over the given message
|
|
184
170
|
*/
|
|
185
171
|
signHashed(messageHashedBytes) {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
return BytesUtils.arrayify(BytesUtils.concat([splitSignature.r, splitSignature.s]));
|
|
191
|
-
});
|
|
172
|
+
const { wallet } = this;
|
|
173
|
+
const signature = wallet.signingKey.sign(messageHashedBytes);
|
|
174
|
+
const splitSignature = BytesUtils.splitSignature(signature);
|
|
175
|
+
return BytesUtils.arrayify(BytesUtils.concat([splitSignature.r, splitSignature.s]));
|
|
192
176
|
}
|
|
193
177
|
/**
|
|
194
178
|
* Sign the given message using the edcsa sign_deterministic function.
|
|
@@ -196,15 +180,13 @@ class PrivateKey {
|
|
|
196
180
|
* @returns {Uint8Array} a signature of this private key over the given message
|
|
197
181
|
*/
|
|
198
182
|
signHashedEcda(messageHashedBytes) {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
return signature;
|
|
207
|
-
});
|
|
183
|
+
const { wallet } = this;
|
|
184
|
+
const privateKeyHex = wallet.privateKey.startsWith('0x')
|
|
185
|
+
? wallet.privateKey.slice(2)
|
|
186
|
+
: wallet.privateKey;
|
|
187
|
+
const privateKey = Uint8Array.from(Buffer.from(privateKeyHex, 'hex'));
|
|
188
|
+
const { signature } = secp256k1_1.default.ecdsaSign(messageHashedBytes, privateKey);
|
|
189
|
+
return signature;
|
|
208
190
|
}
|
|
209
191
|
/**
|
|
210
192
|
* Sign the given typed data using the edcsa sign_deterministic function.
|
|
@@ -212,18 +194,16 @@ class PrivateKey {
|
|
|
212
194
|
* @returns {Uint8Array} a signature of this private key over the given message
|
|
213
195
|
*/
|
|
214
196
|
signTypedData(eip712Data) {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
version: eth_sig_util_1.SignTypedDataVersion.V4,
|
|
224
|
-
});
|
|
225
|
-
return Buffer.from(signature.replace('0x', ''), 'hex');
|
|
197
|
+
const { wallet } = this;
|
|
198
|
+
const privateKeyHex = wallet.privateKey.startsWith('0x')
|
|
199
|
+
? wallet.privateKey.slice(2)
|
|
200
|
+
: wallet.privateKey;
|
|
201
|
+
const signature = (0, eth_sig_util_1.signTypedData)({
|
|
202
|
+
privateKey: Buffer.from(privateKeyHex, 'hex'),
|
|
203
|
+
data: eip712Data,
|
|
204
|
+
version: eth_sig_util_1.SignTypedDataVersion.V4,
|
|
226
205
|
});
|
|
206
|
+
return Buffer.from(signature.replace('0x', ''), 'hex');
|
|
227
207
|
}
|
|
228
208
|
/**
|
|
229
209
|
* Sign the given typed data using the edcsa sign_deterministic function.
|
|
@@ -231,15 +211,13 @@ class PrivateKey {
|
|
|
231
211
|
* @returns {Uint8Array} a signature of this private key over the given message
|
|
232
212
|
*/
|
|
233
213
|
signHashedTypedData(eip712Data) {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
return signature;
|
|
242
|
-
});
|
|
214
|
+
const { wallet } = this;
|
|
215
|
+
const privateKeyHex = wallet.privateKey.startsWith('0x')
|
|
216
|
+
? wallet.privateKey.slice(2)
|
|
217
|
+
: wallet.privateKey;
|
|
218
|
+
const privateKey = Uint8Array.from(Buffer.from(privateKeyHex, 'hex'));
|
|
219
|
+
const { signature } = secp256k1_1.default.ecdsaSign(eip712Data, privateKey);
|
|
220
|
+
return signature;
|
|
243
221
|
}
|
|
244
222
|
/**
|
|
245
223
|
* Verify signature using EIP712 typed data
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrivateKey.js","sourceRoot":"","sources":["../../../../src/core/accounts/PrivateKey.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PrivateKey.js","sourceRoot":"","sources":["../../../../src/core/accounts/PrivateKey.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAAwC;AACxC,mCAA+B;AAC/B,0DAAi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EF,OAAO,IAAI,CAAC,eAAe,CAAC;YAC1B,MAAM,EAAE,eAAe;YACvB,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC;YACjD,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC;SACnE,CAAC,CAAA;IACJ,CAAC;IAED;;;;;;;;;SASK;IACE,MAAM,CAAC,wBAAwB,CAAC,EACrC,SAAS,EACT,OAAO,EACP,SAAS,GAKV;QACC,OAAO,mBAAS,CAAC,WAAW,CAC1B,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,EAC7B,IAAA,mBAAS,EAAC,OAAO,CAAC,EAClB,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAC9B,CAAA;IACH,CAAC;CACF;AAxZD,gCAwZC"}
|
|
@@ -25,7 +25,7 @@ export declare class PrivateKey {
|
|
|
25
25
|
* @param {string|undefined} path the HD path that follows the BIP32 standard (optional)
|
|
26
26
|
* @returns {PrivateKey} Initialized PrivateKey object
|
|
27
27
|
*/
|
|
28
|
-
static fromMnemonic(words: string
|
|
28
|
+
static fromMnemonic(words: string): PrivateKey;
|
|
29
29
|
/**
|
|
30
30
|
* Create a PrivateKey instance from a given private key and a HD derivation path.
|
|
31
31
|
* If path is not given, default to Band's HD prefix 494 and all other indexes being zeroes.
|
|
@@ -72,37 +72,37 @@ export declare class PrivateKey {
|
|
|
72
72
|
* @param {string} messageBytes: the message that will be hashed and signed, a Buffer made of bytes
|
|
73
73
|
* @returns {Uint8Array} a signature of this private key over the given message
|
|
74
74
|
*/
|
|
75
|
-
sign(messageBytes: Buffer):
|
|
75
|
+
sign(messageBytes: Buffer): Uint8Array;
|
|
76
76
|
/**
|
|
77
77
|
* Sign the given message using the edcsa sign_deterministic function.
|
|
78
78
|
* @param {Buffer} messageBytes: the message that will be hashed and signed, a Buffer made of bytes
|
|
79
79
|
* @returns {Uint8Array} a signature of this private key over the given message
|
|
80
80
|
*/
|
|
81
|
-
signEcda(messageBytes: Buffer):
|
|
81
|
+
signEcda(messageBytes: Buffer): Uint8Array;
|
|
82
82
|
/**
|
|
83
83
|
* Sign the given message using the wallet's _signingKey function.
|
|
84
84
|
* @param {string} messageHashedBytes: the message that will be signed, a Buffer made of bytes
|
|
85
85
|
* @returns {Uint8Array} a signature of this private key over the given message
|
|
86
86
|
*/
|
|
87
|
-
signHashed(messageHashedBytes: Buffer):
|
|
87
|
+
signHashed(messageHashedBytes: Buffer): Uint8Array;
|
|
88
88
|
/**
|
|
89
89
|
* Sign the given message using the edcsa sign_deterministic function.
|
|
90
90
|
* @param {Buffer} messageHashedBytes: the message that will be signed, a Buffer made of bytes
|
|
91
91
|
* @returns {Uint8Array} a signature of this private key over the given message
|
|
92
92
|
*/
|
|
93
|
-
signHashedEcda(messageHashedBytes: Buffer):
|
|
93
|
+
signHashedEcda(messageHashedBytes: Buffer): Uint8Array;
|
|
94
94
|
/**
|
|
95
95
|
* Sign the given typed data using the edcsa sign_deterministic function.
|
|
96
96
|
* @param {Buffer} eip712Data: the typed data that will be hashed and signed, a Buffer made of bytes
|
|
97
97
|
* @returns {Uint8Array} a signature of this private key over the given message
|
|
98
98
|
*/
|
|
99
|
-
signTypedData(eip712Data: any):
|
|
99
|
+
signTypedData(eip712Data: any): Uint8Array;
|
|
100
100
|
/**
|
|
101
101
|
* Sign the given typed data using the edcsa sign_deterministic function.
|
|
102
102
|
* @param {Buffer} eip712Data: the typed data that will be signed, a Buffer made of bytes
|
|
103
103
|
* @returns {Uint8Array} a signature of this private key over the given message
|
|
104
104
|
*/
|
|
105
|
-
signHashedTypedData(eip712Data: Buffer):
|
|
105
|
+
signHashedTypedData(eip712Data: Buffer): Uint8Array;
|
|
106
106
|
/**
|
|
107
107
|
* Verify signature using EIP712 typed data
|
|
108
108
|
* and the publicKey
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrivateKey.d.ts","sourceRoot":"","sources":["../../../../src/core/accounts/PrivateKey.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"PrivateKey.d.ts","sourceRoot":"","sources":["../../../../src/core/accounts/PrivateKey.ts"],"names":[],"mappings":";AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAInC,OAAO,EACL,iBAAiB,EAElB,MAAM,8BAA8B,CAAA;AAMrC;;;;GAIG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,MAAM,CAAQ;IAEtB,OAAO;IAIP;;;OAGG;IACH,MAAM,CAAC,QAAQ,IAAI;QAAE,UAAU,EAAE,UAAU,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE;IAU/D;;;;;;OAMG;IACH,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU;IAI9C;;;;;;;OAOG;IACH,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU;IAIrD;;;;;OAKG;IACH,MAAM,CAAC,OAAO,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU,GAAG,UAAU;IAa3D;;;QAGI;IACJ,eAAe,IAAI,MAAM;IAMzB;;;QAGI;IACJ,WAAW,IAAI,SAAS;IAIxB;;;OAGG;IACH,KAAK,IAAI,MAAM;IAMf;;;QAGI;IACJ,SAAS,IAAI,OAAO;IAIpB;;;QAGI;IACJ,QAAQ,IAAI,MAAM;IAIlB;;;;OAIG;IACH,IAAI,CAAC,YAAY,EAAE,MAAM,GAAG,UAAU;IAYtC;;;;OAIG;IACH,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,UAAU;IAa1C;;;;OAIG;IACH,UAAU,CAAC,kBAAkB,EAAE,MAAM,GAAG,UAAU;IAWlD;;;;OAIG;IACH,cAAc,CAAC,kBAAkB,EAAE,MAAM,GAAG,UAAU;IAYtD;;;;OAIG;IACH,aAAa,CAAC,UAAU,EAAE,GAAG,GAAG,UAAU;IAe1C;;;;OAIG;IACH,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU;IAYnD;;;;;;;;;SASK;WACS,eAAe,CAAC,EAC5B,SAAS,EACT,MAAM,EACN,SAAS,GACV,EAAE;QACD,SAAS,EAAE,MAAM,CAAA;QACjB,MAAM,EAAE,GAAG,CAAA;QACX,SAAS,EAAE,MAAM,CAAA;KAClB,GAAG,OAAO;IAqBX;;;;;;;;;SASK;IACE,qBAAqB,CAAC,EAC3B,SAAS,EACT,MAAM,GACP,EAAE;QACD,SAAS,EAAE,MAAM,CAAA;QACjB,MAAM,EAAE,GAAG,CAAA;KACZ,GAAG,OAAO;IAkBX;;;;;;;;;QASI;WACU,qBAAqB,CAAC,EAClC,KAAK,EACL,MAAM,GACP,EAAE;QACD,KAAK,EAAE,iBAAiB,CAAC,KAAK,CAAA;QAC9B,MAAM,EAAE;YACN,aAAa,EAAE,MAAM,GAAG,MAAM,CAAA;YAC9B,SAAS,EAAE,MAAM,CAAA;SAClB,CAAA;KACF,GAAG,OAAO;IA+EX;;;;;;;;;SASK;WACS,wBAAwB,CAAC,EACrC,SAAS,EACT,OAAO,EACP,SAAS,GACV,EAAE;QACD,SAAS,EAAE,MAAM,CAAA;QACjB,OAAO,EAAE,MAAM,CAAA;QACf,SAAS,EAAE,MAAM,CAAA;KAClB,GAAG,OAAO;CAOZ"}
|
|
@@ -2,7 +2,6 @@ import { generateMnemonic } from 'bip39';
|
|
|
2
2
|
import { Wallet } from 'ethers';
|
|
3
3
|
import secp256k1 from 'secp256k1';
|
|
4
4
|
import keccak256 from 'keccak256';
|
|
5
|
-
import { DEFAULT_DERIVATION_PATH } from '../../utils/constants';
|
|
6
5
|
import { PublicKey } from './PublicKey';
|
|
7
6
|
import { Address } from './Address';
|
|
8
7
|
import * as BytesUtils from '@ethersproject/bytes';
|
|
@@ -42,8 +41,8 @@ export class PrivateKey {
|
|
|
42
41
|
* @param {string|undefined} path the HD path that follows the BIP32 standard (optional)
|
|
43
42
|
* @returns {PrivateKey} Initialized PrivateKey object
|
|
44
43
|
*/
|
|
45
|
-
static fromMnemonic(words
|
|
46
|
-
return new PrivateKey(Wallet.
|
|
44
|
+
static fromMnemonic(words) {
|
|
45
|
+
return new PrivateKey(new Wallet(Wallet.fromPhrase(words).signingKey));
|
|
47
46
|
}
|
|
48
47
|
/**
|
|
49
48
|
* Create a PrivateKey instance from a given private key and a HD derivation path.
|
|
@@ -68,7 +67,7 @@ export class PrivateKey {
|
|
|
68
67
|
const privateKeyBuff = isString
|
|
69
68
|
? Buffer.from(privateKeyHex.toString(), 'hex')
|
|
70
69
|
: privateKey;
|
|
71
|
-
return new PrivateKey(new Wallet(privateKeyBuff));
|
|
70
|
+
return new PrivateKey(new Wallet(Buffer.from(privateKeyBuff).toString('hex')));
|
|
72
71
|
}
|
|
73
72
|
/**
|
|
74
73
|
* Return the private key in hex
|
|
@@ -114,10 +113,10 @@ export class PrivateKey {
|
|
|
114
113
|
* @param {string} messageBytes: the message that will be hashed and signed, a Buffer made of bytes
|
|
115
114
|
* @returns {Uint8Array} a signature of this private key over the given message
|
|
116
115
|
*/
|
|
117
|
-
|
|
116
|
+
sign(messageBytes) {
|
|
118
117
|
const { wallet } = this;
|
|
119
118
|
const msgHash = keccak256(messageBytes);
|
|
120
|
-
const signature =
|
|
119
|
+
const signature = wallet.signingKey.sign(msgHash);
|
|
121
120
|
const splitSignature = BytesUtils.splitSignature(signature);
|
|
122
121
|
return BytesUtils.arrayify(BytesUtils.concat([splitSignature.r, splitSignature.s]));
|
|
123
122
|
}
|
|
@@ -126,7 +125,7 @@ export class PrivateKey {
|
|
|
126
125
|
* @param {Buffer} messageBytes: the message that will be hashed and signed, a Buffer made of bytes
|
|
127
126
|
* @returns {Uint8Array} a signature of this private key over the given message
|
|
128
127
|
*/
|
|
129
|
-
|
|
128
|
+
signEcda(messageBytes) {
|
|
130
129
|
const { wallet } = this;
|
|
131
130
|
const msgHash = keccak256(messageBytes);
|
|
132
131
|
const privateKeyHex = wallet.privateKey.startsWith('0x')
|
|
@@ -141,9 +140,9 @@ export class PrivateKey {
|
|
|
141
140
|
* @param {string} messageHashedBytes: the message that will be signed, a Buffer made of bytes
|
|
142
141
|
* @returns {Uint8Array} a signature of this private key over the given message
|
|
143
142
|
*/
|
|
144
|
-
|
|
143
|
+
signHashed(messageHashedBytes) {
|
|
145
144
|
const { wallet } = this;
|
|
146
|
-
const signature =
|
|
145
|
+
const signature = wallet.signingKey.sign(messageHashedBytes);
|
|
147
146
|
const splitSignature = BytesUtils.splitSignature(signature);
|
|
148
147
|
return BytesUtils.arrayify(BytesUtils.concat([splitSignature.r, splitSignature.s]));
|
|
149
148
|
}
|
|
@@ -152,7 +151,7 @@ export class PrivateKey {
|
|
|
152
151
|
* @param {Buffer} messageHashedBytes: the message that will be signed, a Buffer made of bytes
|
|
153
152
|
* @returns {Uint8Array} a signature of this private key over the given message
|
|
154
153
|
*/
|
|
155
|
-
|
|
154
|
+
signHashedEcda(messageHashedBytes) {
|
|
156
155
|
const { wallet } = this;
|
|
157
156
|
const privateKeyHex = wallet.privateKey.startsWith('0x')
|
|
158
157
|
? wallet.privateKey.slice(2)
|
|
@@ -166,7 +165,7 @@ export class PrivateKey {
|
|
|
166
165
|
* @param {Buffer} eip712Data: the typed data that will be hashed and signed, a Buffer made of bytes
|
|
167
166
|
* @returns {Uint8Array} a signature of this private key over the given message
|
|
168
167
|
*/
|
|
169
|
-
|
|
168
|
+
signTypedData(eip712Data) {
|
|
170
169
|
const { wallet } = this;
|
|
171
170
|
const privateKeyHex = wallet.privateKey.startsWith('0x')
|
|
172
171
|
? wallet.privateKey.slice(2)
|
|
@@ -183,7 +182,7 @@ export class PrivateKey {
|
|
|
183
182
|
* @param {Buffer} eip712Data: the typed data that will be signed, a Buffer made of bytes
|
|
184
183
|
* @returns {Uint8Array} a signature of this private key over the given message
|
|
185
184
|
*/
|
|
186
|
-
|
|
185
|
+
signHashedTypedData(eip712Data) {
|
|
187
186
|
const { wallet } = this;
|
|
188
187
|
const privateKeyHex = wallet.privateKey.startsWith('0x')
|
|
189
188
|
? wallet.privateKey.slice(2)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrivateKey.js","sourceRoot":"","sources":["../../../../src/core/accounts/PrivateKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAA;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,SAAS,MAAM,WAAW,CAAA;AACjC,OAAO,SAAS,MAAM,WAAW,CAAA;AACjC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"PrivateKey.js","sourceRoot":"","sources":["../../../../src/core/accounts/PrivateKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAA;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,SAAS,MAAM,WAAW,CAAA;AACjC,OAAO,SAAS,MAAM,WAAW,CAAA;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,KAAK,UAAU,MAAM,sBAAsB,CAAA;AAClD,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAC5E,OAAO,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAA;AACzD,OAAO,EAEL,qBAAqB,GACtB,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAA;AACrE,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAC5D,OAAO,EAAE,OAAO,EAA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AAI,CAAC,MAAM,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC;SACnE,CAAC,CAAA;IACJ,CAAC;IAED;;;;;;;;;SASK;IACE,MAAM,CAAC,wBAAwB,CAAC,EACrC,SAAS,EACT,OAAO,EACP,SAAS,GAKV;QACC,OAAO,SAAS,CAAC,WAAW,CAC1B,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,EAC7B,SAAS,CAAC,OAAO,CAAC,EAClB,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAC9B,CAAA;IACH,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@injectivelabs/sdk-ts",
|
|
3
3
|
"description": "SDK in TypeScript for building Injective applications in a browser, node, and react native environment.",
|
|
4
|
-
"version": "1.14.13-beta.
|
|
4
|
+
"version": "1.14.13-beta.2",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"author": {
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"bip39": "^3.0.4",
|
|
57
57
|
"cosmjs-types": "^0.9.0",
|
|
58
58
|
"ethereumjs-util": "^7.1.4",
|
|
59
|
-
"ethers": "^5.
|
|
59
|
+
"ethers": "^6.5.1",
|
|
60
60
|
"google-protobuf": "^3.21.0",
|
|
61
61
|
"graphql": "^16.3.0",
|
|
62
62
|
"http-status-codes": "^2.2.0",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"shx": "^0.3.2",
|
|
69
69
|
"snakecase-keys": "^5.4.1"
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "9562fbe7af4286b7fbc903ca5f78e1c6025805be",
|
|
72
72
|
"typedoc": {
|
|
73
73
|
"entryPoint": "./src/index.ts",
|
|
74
74
|
"readmeFile": "./README.md",
|