@injectivelabs/sdk-ts 1.0.50 → 1.0.53
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
CHANGED
|
@@ -9,15 +9,15 @@ _Accessing decentralized finance through TypeScript (for Web and Node environmen
|
|
|
9
9
|
`@injectivelabs/sdk-ts` is a TypeScript SDK for writing applications on top of the Injective chain in both a Node.js and a browser environment.
|
|
10
10
|
|
|
11
11
|
<p align="center">
|
|
12
|
-
<a href="
|
|
12
|
+
<a href="https://github.com/injectivelabs/sdk-ts" target="_blank"><strong>Documentation</strong></a>
|
|
13
13
|
·
|
|
14
|
-
<a href="https://github.com/InjectiveLabs/sdk-ts-examples">Examples</a>
|
|
14
|
+
<a href="https://github.com/InjectiveLabs/sdk-ts-examples" target="_blank">Examples</a>
|
|
15
15
|
·
|
|
16
|
-
<a href="
|
|
16
|
+
<a href="https://injectivelabs.github.io/injective-ts/modules/_injectivelabs_sdk_ts.html" target="_blank">API Reference</a>
|
|
17
17
|
·
|
|
18
|
-
<a href="https://www.npmjs.com/package/@injectivelabs/sdk-ts">NPM Package</a>
|
|
18
|
+
<a href="https://www.npmjs.com/package/@injectivelabs/sdk-ts" target="_blank">NPM Package</a>
|
|
19
19
|
·
|
|
20
|
-
<a href="https://github.com/injectivelabs/sdk-ts">GitHub</a>
|
|
20
|
+
<a href="https://github.com/injectivelabs/sdk-ts" target="_blank">GitHub</a>
|
|
21
21
|
</p>
|
|
22
22
|
|
|
23
23
|
### ✨ Features
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import { PublicKey } from './PublicKey';
|
|
2
3
|
import { Address } from '../classes/Address';
|
|
3
4
|
/**
|
|
@@ -49,11 +50,17 @@ export declare class PrivateKey {
|
|
|
49
50
|
* @returns {string}
|
|
50
51
|
**/
|
|
51
52
|
toBech32(): string;
|
|
53
|
+
/**
|
|
54
|
+
* Sign the given message using the wallet's _signingKey function.
|
|
55
|
+
* @param {string} messageBytes: the message that will be hashed and signed, a Buffer made of bytes
|
|
56
|
+
* @returns {Uint8Array} a signature of this private key over the given message
|
|
57
|
+
*/
|
|
58
|
+
sign(messageBytes: Buffer): Promise<Uint8Array>;
|
|
52
59
|
/**
|
|
53
60
|
* Sign the given message using the edcsa sign_deterministic function.
|
|
54
|
-
* @param {
|
|
55
|
-
* @returns {
|
|
61
|
+
* @param {Buffer} messageBytes: the message that will be hashed and signed, a Buffer made of bytes
|
|
62
|
+
* @returns {Uint8Array} a signature of this private key over the given message
|
|
56
63
|
*/
|
|
57
|
-
|
|
64
|
+
signEcda(messageBytes: Buffer): Promise<Uint8Array>;
|
|
58
65
|
}
|
|
59
66
|
//# sourceMappingURL=PrivateKey.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrivateKey.d.ts","sourceRoot":"","sources":["../../src/local/PrivateKey.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"PrivateKey.d.ts","sourceRoot":"","sources":["../../src/local/PrivateKey.ts"],"names":[],"mappings":";AAKA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAG5C;;GAEG;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,CACjB,KAAK,EAAE,MAAM,EACb,IAAI,GAAE,MAAM,GAAG,SAAmC,GACjD,UAAU;IAIb;;;;;OAKG;IACH,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU;IAIrD;;;OAGG;IACH,KAAK,IAAI,MAAM;IAMf;;;QAGI;IACJ,WAAW,IAAI,SAAS;IAIxB;;;QAGI;IACJ,SAAS,IAAI,OAAO;IAIpB;;;QAGI;IACJ,QAAQ,IAAI,MAAM;IAIlB;;;;OAIG;IACG,IAAI,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAYrD;;;;OAIG;IACG,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;CAY1D"}
|
package/dist/local/PrivateKey.js
CHANGED
|
@@ -1,4 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
2
21
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
22
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
23
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -20,6 +39,7 @@ const keccak256_1 = __importDefault(require("keccak256"));
|
|
|
20
39
|
const constants_1 = require("../utils/constants");
|
|
21
40
|
const PublicKey_1 = require("./PublicKey");
|
|
22
41
|
const Address_1 = require("../classes/Address");
|
|
42
|
+
const BytesUtils = __importStar(require("@ethersproject/bytes"));
|
|
23
43
|
/**
|
|
24
44
|
* Class for wrapping SigningKey that is used for signature creation and public key derivation.
|
|
25
45
|
*/
|
|
@@ -88,15 +108,29 @@ class PrivateKey {
|
|
|
88
108
|
toBech32() {
|
|
89
109
|
return Address_1.Address.fromHex(this.toHex()).toBech32();
|
|
90
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* Sign the given message using the wallet's _signingKey function.
|
|
113
|
+
* @param {string} messageBytes: the message that will be hashed and signed, a Buffer made of bytes
|
|
114
|
+
* @returns {Uint8Array} a signature of this private key over the given message
|
|
115
|
+
*/
|
|
116
|
+
sign(messageBytes) {
|
|
117
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
118
|
+
const { wallet } = this;
|
|
119
|
+
const msgHash = (0, keccak256_1.default)(messageBytes);
|
|
120
|
+
const signature = yield wallet._signingKey().signDigest(msgHash);
|
|
121
|
+
const splitSignature = BytesUtils.splitSignature(signature);
|
|
122
|
+
return BytesUtils.arrayify(BytesUtils.concat([splitSignature.r, splitSignature.s]));
|
|
123
|
+
});
|
|
124
|
+
}
|
|
91
125
|
/**
|
|
92
126
|
* Sign the given message using the edcsa sign_deterministic function.
|
|
93
|
-
* @param {
|
|
94
|
-
* @returns {
|
|
127
|
+
* @param {Buffer} messageBytes: the message that will be hashed and signed, a Buffer made of bytes
|
|
128
|
+
* @returns {Uint8Array} a signature of this private key over the given message
|
|
95
129
|
*/
|
|
96
|
-
|
|
130
|
+
signEcda(messageBytes) {
|
|
97
131
|
return __awaiter(this, void 0, void 0, function* () {
|
|
98
132
|
const { wallet } = this;
|
|
99
|
-
const msgHash = (0, keccak256_1.default)(
|
|
133
|
+
const msgHash = (0, keccak256_1.default)(messageBytes);
|
|
100
134
|
const privateKeyHex = wallet.privateKey.startsWith('0x')
|
|
101
135
|
? wallet.privateKey.slice(2)
|
|
102
136
|
: wallet.privateKey;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrivateKey.js","sourceRoot":"","sources":["../../src/local/PrivateKey.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PrivateKey.js","sourceRoot":"","sources":["../../src/local/PrivateKey.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAyB;AACzB,mCAA+B;AAC/B,0DAAiC;AACjC,0DAAiC;AACjC,kDAA4D;AAC5D,2CAAuC;AACvC,gDAA4C;AAC5C,iEAAkD;AAElD;;GAEG;AACH,MAAa,UAAU;IAGrB,YAAoB,MAAc;QAChC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,QAAQ;QACb,MAAM,QAAQ,GAAG,eAAK,CAAC,gBAAgB,EAAE,CAAA;QACzC,MAAM,UAAU,GAAG,UAAU,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAA;QAEpD,OAAO;YACL,UAAU;YACV,QAAQ;SACT,CAAA;IACH,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,YAAY,CACjB,KAAa,EACb,OAA2B,mCAAuB;QAElD,OAAO,IAAI,UAAU,CAAC,eAAM,CAAC,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAA;IACzD,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,cAAc,CAAC,UAAkB;QACtC,OAAO,IAAI,UAAU,CAAC,IAAI,eAAM,CAAC,UAAU,CAAC,CAAC,CAAA;IAC/C,CAAC;IAED;;;OAGG;IACH,KAAK;QACH,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC;YACzC,CAAC,C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,CAAC,MAAM,CAAC,UAAU,CAAA;YACrB,MAAM,UAAU,GAAG,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC,CAAA;YACrE,MAAM,EAAE,SAAS,EAAE,GAAG,mBAAS,CAAC,SAAS,CAAC,OAAO,EAAE,UAAU,CAAC,CAAA;YAE9D,OAAO,SAAS,CAAA;QAClB,CAAC;KAAA;CACF;AAjHD,gCAiHC"}
|
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 Node environment.",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.53",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Bojan Angjelkoski",
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"shx": "^0.3.2",
|
|
58
58
|
"snakecase-keys": "^5.4.1"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "c9d0dea3cd205251531ac1658dddffaeb2818388"
|
|
61
61
|
}
|