@cityofzion/bs-neo3 0.11.4 → 0.13.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/dist/LedgerServiceNeo3.d.ts +2 -1
- package/dist/LedgerServiceNeo3.js +9 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +2 -2
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { Account, LedgerService } from '@cityofzion/blockchain-service';
|
|
1
|
+
import { Account, LedgerService, LedgerServiceEmitter } from '@cityofzion/blockchain-service';
|
|
2
2
|
import Transport from '@ledgerhq/hw-transport';
|
|
3
3
|
import { api } from '@cityofzion/neon-js';
|
|
4
4
|
export declare class LedgerServiceNeo3 implements LedgerService {
|
|
5
5
|
getLedgerTransport?: ((account: Account) => Promise<Transport>) | undefined;
|
|
6
|
+
emitter: LedgerServiceEmitter;
|
|
6
7
|
constructor(getLedgerTransport?: ((account: Account) => Promise<Transport>) | undefined);
|
|
7
8
|
getAddress(transport: Transport): Promise<string>;
|
|
8
9
|
getSigningCallback(transport: Transport): api.SigningFunction;
|
|
@@ -8,13 +8,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
15
|
exports.LedgerServiceNeo3 = void 0;
|
|
13
16
|
const neon_js_1 = require("@cityofzion/neon-js");
|
|
14
17
|
const neon_dappkit_1 = require("@cityofzion/neon-dappkit");
|
|
18
|
+
const events_1 = __importDefault(require("events"));
|
|
15
19
|
class LedgerServiceNeo3 {
|
|
16
20
|
constructor(getLedgerTransport) {
|
|
17
21
|
this.getLedgerTransport = getLedgerTransport;
|
|
22
|
+
this.emitter = new events_1.default();
|
|
18
23
|
}
|
|
19
24
|
getAddress(transport) {
|
|
20
25
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -37,6 +42,7 @@ class LedgerServiceNeo3 {
|
|
|
37
42
|
}
|
|
38
43
|
getSignature(transport, serializedTransaction, networkMagic, addressIndex = 0) {
|
|
39
44
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
this.emitter.emit('getSignatureStart');
|
|
40
46
|
const bip44Buffer = this.toBip44Buffer(addressIndex);
|
|
41
47
|
yield transport.send(0x80, 0x02, 0, 0x80, bip44Buffer, [0x9000]);
|
|
42
48
|
yield transport.send(0x80, 0x02, 1, 0x80, Buffer.from(neon_dappkit_1.NeonParser.numToHex(networkMagic, 4, true), 'hex'), [0x9000]);
|
|
@@ -48,7 +54,9 @@ class LedgerServiceNeo3 {
|
|
|
48
54
|
if (response.length <= 2) {
|
|
49
55
|
throw new Error(`No more data but Ledger did not return signature!`);
|
|
50
56
|
}
|
|
51
|
-
|
|
57
|
+
const signature = this.derSignatureToHex(response.toString('hex'));
|
|
58
|
+
this.emitter.emit('getSignatureEnd');
|
|
59
|
+
return signature;
|
|
52
60
|
});
|
|
53
61
|
}
|
|
54
62
|
getPublicKey(transport, addressIndex = 0) {
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cityofzion/bs-neo3",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"repository": "https://github.com/CityOfZion/blockchain-services",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"@cityofzion/neon-dappkit": "0.4.1",
|
|
20
20
|
"@cityofzion/neon-dappkit-types": "~0.3.1",
|
|
21
21
|
"@ledgerhq/hw-transport-node-hid": "~6.28.5",
|
|
22
|
-
"@cityofzion/blockchain-service": "0.
|
|
22
|
+
"@cityofzion/blockchain-service": "0.12.0",
|
|
23
23
|
"@cityofzion/bs-asteroid-sdk": "0.8.1"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|