@keystonehq/hw-app-tron 0.0.1 → 0.0.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/lib/index.d.ts +30 -4
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +36 -6
- package/lib/index.js.map +1 -1
- package/package.json +4 -4
- package/src/index.ts +38 -8
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Base from '@keystonehq/hw-app-base';
|
|
2
2
|
import { TransportHID } from '@keystonehq/hw-transport-usb';
|
|
3
|
+
import { DataType } from '@keystonehq/bc-ur-registry-tron';
|
|
3
4
|
import { UR } from '@ngraveio/bc-ur';
|
|
4
5
|
/**
|
|
5
6
|
* Tron Hardware Wallet Application.
|
|
@@ -16,7 +17,11 @@ export default class Tron extends Base {
|
|
|
16
17
|
/**
|
|
17
18
|
* Signs a Tron transaction using the specified derivation path.
|
|
18
19
|
*/
|
|
19
|
-
signTransactionBuffer(path: string, rawTx: Buffer, xfp: string, origin: string): Promise<
|
|
20
|
+
signTransactionBuffer(path: string, rawTx: Buffer, xfp: string, origin: string, type: DataType): Promise<{
|
|
21
|
+
r: string;
|
|
22
|
+
s: string;
|
|
23
|
+
v: string;
|
|
24
|
+
}>;
|
|
20
25
|
/**
|
|
21
26
|
* signs a Tron transaction given the raw transaction data in hexadecimal format.
|
|
22
27
|
* @param path
|
|
@@ -25,7 +30,24 @@ export default class Tron extends Base {
|
|
|
25
30
|
* @param origin
|
|
26
31
|
* @returns
|
|
27
32
|
*/
|
|
28
|
-
signTransaction(path: string, rawTx: string, xfp: string, origin: string): Promise<
|
|
33
|
+
signTransaction(path: string, rawTx: string, xfp: string, origin: string): Promise<{
|
|
34
|
+
r: string;
|
|
35
|
+
s: string;
|
|
36
|
+
v: string;
|
|
37
|
+
}>;
|
|
38
|
+
/**
|
|
39
|
+
* signs a personal message with the given path, message, xfp, and origin.
|
|
40
|
+
* @param path
|
|
41
|
+
* @param message
|
|
42
|
+
* @param xfp
|
|
43
|
+
* @param origin
|
|
44
|
+
* @returns
|
|
45
|
+
*/
|
|
46
|
+
signPersonalMessage(path: string, message: string, xfp: string, origin: string): Promise<{
|
|
47
|
+
r: string;
|
|
48
|
+
s: string;
|
|
49
|
+
v: string;
|
|
50
|
+
}>;
|
|
29
51
|
/**
|
|
30
52
|
* Constructs a UR-encoded request for Tron signing.
|
|
31
53
|
*
|
|
@@ -35,13 +57,17 @@ export default class Tron extends Base {
|
|
|
35
57
|
* @param origin - The origin of the signing request, used for user confirmation on the device.
|
|
36
58
|
* @returns A string representing the UR-encoded request in uppercase.
|
|
37
59
|
*/
|
|
38
|
-
generateSignRequest(txBuffer: Buffer, path: string, mfp: string, origin: string): string;
|
|
60
|
+
generateSignRequest(txBuffer: Buffer, path: string, mfp: string, origin: string, type: DataType): string;
|
|
39
61
|
/**
|
|
40
62
|
* Parses the UR response from the device to extract the Tron signature.
|
|
41
63
|
*
|
|
42
64
|
* @param ur - The result UR from the device.
|
|
43
65
|
* @returns The signature string in hexadecimal format.
|
|
44
66
|
*/
|
|
45
|
-
parseSignature(ur: UR):
|
|
67
|
+
parseSignature(ur: UR): {
|
|
68
|
+
r: string;
|
|
69
|
+
s: string;
|
|
70
|
+
v: string;
|
|
71
|
+
};
|
|
46
72
|
}
|
|
47
73
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,IAA0B,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAW,YAAY,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,IAA0B,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAW,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACrE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Y/B"}
|
package/lib/index.js
CHANGED
|
@@ -64,10 +64,10 @@ class Tron extends hw_app_base_1.default {
|
|
|
64
64
|
/**
|
|
65
65
|
* Signs a Tron transaction using the specified derivation path.
|
|
66
66
|
*/
|
|
67
|
-
signTransactionBuffer(path, rawTx, xfp, origin) {
|
|
67
|
+
signTransactionBuffer(path, rawTx, xfp, origin, type) {
|
|
68
68
|
return __awaiter(this, void 0, void 0, function* () {
|
|
69
69
|
this.precheck();
|
|
70
|
-
const encodedUR = this.generateSignRequest(rawTx, path, xfp || this.mfp, origin);
|
|
70
|
+
const encodedUR = this.generateSignRequest(rawTx, path, xfp || this.mfp, origin, type);
|
|
71
71
|
const response = yield this.sendToDevice(hw_transport_usb_1.Actions.CMD_RESOLVE_UR, encodedUR);
|
|
72
72
|
const resultUR = (0, hw_app_base_1.parseResponoseUR)(response.payload);
|
|
73
73
|
return this.parseSignature(resultUR);
|
|
@@ -83,7 +83,29 @@ class Tron extends hw_app_base_1.default {
|
|
|
83
83
|
*/
|
|
84
84
|
signTransaction(path, rawTx, xfp, origin) {
|
|
85
85
|
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
-
return yield this.signTransactionBuffer(path, Buffer.from(rawTx, 'hex'), xfp, origin);
|
|
86
|
+
return yield this.signTransactionBuffer(path, Buffer.from(rawTx, 'hex'), xfp, origin, bc_ur_registry_tron_1.DataType.transaction);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* signs a personal message with the given path, message, xfp, and origin.
|
|
91
|
+
* @param path
|
|
92
|
+
* @param message
|
|
93
|
+
* @param xfp
|
|
94
|
+
* @param origin
|
|
95
|
+
* @returns
|
|
96
|
+
*/
|
|
97
|
+
signPersonalMessage(path, message, xfp, origin) {
|
|
98
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
99
|
+
let messageBuffer;
|
|
100
|
+
const isHex = /^(0x)?[0-9a-fA-F]+$/.test(message) && message.length % 2 === 0;
|
|
101
|
+
if (isHex) {
|
|
102
|
+
const cleanHex = message.startsWith('0x') ? message.slice(2) : message;
|
|
103
|
+
messageBuffer = Buffer.from(cleanHex, 'hex');
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
messageBuffer = Buffer.from(message, 'utf-8');
|
|
107
|
+
}
|
|
108
|
+
return yield this.signTransactionBuffer(path, messageBuffer, xfp || this.mfp, origin, bc_ur_registry_tron_1.DataType.personalMessage);
|
|
87
109
|
});
|
|
88
110
|
}
|
|
89
111
|
/**
|
|
@@ -95,9 +117,9 @@ class Tron extends hw_app_base_1.default {
|
|
|
95
117
|
* @param origin - The origin of the signing request, used for user confirmation on the device.
|
|
96
118
|
* @returns A string representing the UR-encoded request in uppercase.
|
|
97
119
|
*/
|
|
98
|
-
generateSignRequest(txBuffer, path, mfp, origin) {
|
|
120
|
+
generateSignRequest(txBuffer, path, mfp, origin, type) {
|
|
99
121
|
const requestId = uuid.v4();
|
|
100
|
-
const tronUR = bc_ur_registry_tron_1.TronSignRequest.constructTronRequest(txBuffer, path, mfp, requestId, undefined, origin);
|
|
122
|
+
const tronUR = bc_ur_registry_tron_1.TronSignRequest.constructTronRequest(txBuffer, type, path, mfp, requestId, undefined, origin);
|
|
101
123
|
const ur = tronUR.toUR();
|
|
102
124
|
return new bc_ur_1.UREncoder(ur, Infinity).nextPart().toUpperCase();
|
|
103
125
|
}
|
|
@@ -109,7 +131,15 @@ class Tron extends hw_app_base_1.default {
|
|
|
109
131
|
*/
|
|
110
132
|
parseSignature(ur) {
|
|
111
133
|
const signature = bc_ur_registry_tron_1.TronSignature.fromCBOR(ur.cbor);
|
|
112
|
-
|
|
134
|
+
const signatureBuffer = signature.getSignature();
|
|
135
|
+
const r = signatureBuffer.slice(0, 32).toString('hex');
|
|
136
|
+
const s = signatureBuffer.slice(32, 64).toString('hex');
|
|
137
|
+
const v = signatureBuffer.slice(64).toString('hex');
|
|
138
|
+
return {
|
|
139
|
+
r,
|
|
140
|
+
s,
|
|
141
|
+
v,
|
|
142
|
+
};
|
|
113
143
|
}
|
|
114
144
|
;
|
|
115
145
|
}
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAC7B,uEAAiE;AACjE,mEAAqE;AACrE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAC7B,uEAAiE;AACjE,mEAAqE;AACrE,yEAA2F;AAC3F,2CAAgD;AAEhD;;;GAGG;AACH,MAAqB,IAAK,SAAQ,qBAAI;IAClC;;;;;OAKG;IACH,YAAY,SAAuB,EAAE,GAAY;QAC7C,KAAK,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;IAC1B,CAAC;IAED;;OAEG;IACG,qBAAqB,CAAC,IAAY,EAAE,KAAa,EAAE,GAAW,EAAE,MAAc,EAAE,IAAc;;YAChG,IAAI,CAAC,QAAQ,EAAE,CAAC;YAChB,MAAM,SAAS,GAAG,IAAI,CAAC,mBAAmB,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI,IAAI,CAAC,GAAI,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;YACxF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,0BAAO,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC;YAC5E,MAAM,QAAQ,GAAG,IAAA,8BAAgB,EAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;YAEpD,OAAO,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;QACzC,CAAC;KAAA;IAED;;;;;;;OAOG;IACG,eAAe,CAAC,IAAY,EAAE,KAAa,EAAE,GAAW,EAAE,MAAc;;YAC1E,OAAO,MA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G,MAAM,CAAC,IAAI,EAAE,CAAC;QACzB,OAAO,IAAI,iBAAS,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC,QAAQ,EAAE,CAAC,WAAW,EAAE,CAAC;IAChE,CAAC;IAED;;;;;OAKG;IACI,cAAc,CAAC,EAAM;QACxB,MAAM,SAAS,GAAG,mCAAa,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;QAClD,MAAM,eAAe,GAAG,SAAS,CAAC,YAAY,EAAE,CAAC;QACjD,MAAM,CAAC,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACvD,MAAM,CAAC,GAAG,eAAe,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACxD,MAAM,CAAC,GAAG,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACpD,OAAO;YACH,CAAC;YACD,CAAC;YACD,CAAC;SACJ,CAAC;IACN,CAAC;IAAA,CAAC;CACL;AAnGD,uBAmGC"}
|
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@keystonehq/hw-app-tron",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"types": "lib/index.d.ts",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@keystonehq/bc-ur-registry": "0.7.0",
|
|
8
|
-
"@keystonehq/bc-ur-registry-tron": "0.
|
|
8
|
+
"@keystonehq/bc-ur-registry-tron": "0.5.0",
|
|
9
9
|
"@ngraveio/bc-ur": "^1.1.6",
|
|
10
10
|
"@noble/hashes": "^1.5.0",
|
|
11
11
|
"bech32": "^2.0.0",
|
|
12
12
|
"uuid": "^8.3.2",
|
|
13
13
|
"@keystonehq/hw-app-base": "^0.1.7",
|
|
14
|
-
"@keystonehq/hw-transport-
|
|
15
|
-
"@keystonehq/hw-transport-
|
|
14
|
+
"@keystonehq/hw-transport-error": "^0.0.2",
|
|
15
|
+
"@keystonehq/hw-transport-usb": "^0.2.0"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"@types/jest": "^27.5.2",
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as uuid from 'uuid';
|
|
2
2
|
import Base, { parseResponoseUR } from '@keystonehq/hw-app-base';
|
|
3
3
|
import { Actions, TransportHID } from '@keystonehq/hw-transport-usb';
|
|
4
|
-
import { TronSignRequest, TronSignature } from '@keystonehq/bc-ur-registry-tron';
|
|
4
|
+
import { TronSignRequest, TronSignature, DataType } from '@keystonehq/bc-ur-registry-tron';
|
|
5
5
|
import { UREncoder, UR } from '@ngraveio/bc-ur';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -22,9 +22,9 @@ export default class Tron extends Base {
|
|
|
22
22
|
/**
|
|
23
23
|
* Signs a Tron transaction using the specified derivation path.
|
|
24
24
|
*/
|
|
25
|
-
async signTransactionBuffer(path: string, rawTx: Buffer, xfp: string, origin: string): Promise<string> {
|
|
25
|
+
async signTransactionBuffer(path: string, rawTx: Buffer, xfp: string, origin: string, type: DataType): Promise<{ r: string, s: string, v: string }> {
|
|
26
26
|
this.precheck();
|
|
27
|
-
const encodedUR = this.generateSignRequest(rawTx, path, xfp || this.mfp!, origin);
|
|
27
|
+
const encodedUR = this.generateSignRequest(rawTx, path, xfp || this.mfp!, origin, type);
|
|
28
28
|
const response = await this.sendToDevice(Actions.CMD_RESOLVE_UR, encodedUR);
|
|
29
29
|
const resultUR = parseResponoseUR(response.payload);
|
|
30
30
|
|
|
@@ -39,8 +39,29 @@ export default class Tron extends Base {
|
|
|
39
39
|
* @param origin
|
|
40
40
|
* @returns
|
|
41
41
|
*/
|
|
42
|
-
async signTransaction(path: string, rawTx: string, xfp: string, origin: string): Promise<string> {
|
|
43
|
-
return await this.signTransactionBuffer(path, Buffer.from(rawTx, 'hex'), xfp, origin);
|
|
42
|
+
async signTransaction(path: string, rawTx: string, xfp: string, origin: string): Promise<{ r: string, s: string, v: string }> {
|
|
43
|
+
return await this.signTransactionBuffer(path, Buffer.from(rawTx, 'hex'), xfp, origin, DataType.transaction);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* signs a personal message with the given path, message, xfp, and origin.
|
|
48
|
+
* @param path
|
|
49
|
+
* @param message
|
|
50
|
+
* @param xfp
|
|
51
|
+
* @param origin
|
|
52
|
+
* @returns
|
|
53
|
+
*/
|
|
54
|
+
async signPersonalMessage(path: string, message: string, xfp: string, origin: string): Promise<{ r: string, s: string, v: string }> {
|
|
55
|
+
let messageBuffer: Buffer;
|
|
56
|
+
const isHex = /^(0x)?[0-9a-fA-F]+$/.test(message) && message.length % 2 === 0;
|
|
57
|
+
|
|
58
|
+
if (isHex) {
|
|
59
|
+
const cleanHex = message.startsWith('0x') ? message.slice(2) : message;
|
|
60
|
+
messageBuffer = Buffer.from(cleanHex, 'hex');
|
|
61
|
+
} else {
|
|
62
|
+
messageBuffer = Buffer.from(message, 'utf-8');
|
|
63
|
+
}
|
|
64
|
+
return await this.signTransactionBuffer(path, messageBuffer, xfp || this.mfp!, origin, DataType.personalMessage);
|
|
44
65
|
}
|
|
45
66
|
|
|
46
67
|
/**
|
|
@@ -52,10 +73,11 @@ export default class Tron extends Base {
|
|
|
52
73
|
* @param origin - The origin of the signing request, used for user confirmation on the device.
|
|
53
74
|
* @returns A string representing the UR-encoded request in uppercase.
|
|
54
75
|
*/
|
|
55
|
-
public generateSignRequest(txBuffer: Buffer, path: string, mfp: string, origin: string): string {
|
|
76
|
+
public generateSignRequest(txBuffer: Buffer, path: string, mfp: string, origin: string, type: DataType): string {
|
|
56
77
|
const requestId = uuid.v4();
|
|
57
78
|
const tronUR = TronSignRequest.constructTronRequest(
|
|
58
79
|
txBuffer,
|
|
80
|
+
type,
|
|
59
81
|
path,
|
|
60
82
|
mfp,
|
|
61
83
|
requestId,
|
|
@@ -73,9 +95,17 @@ export default class Tron extends Base {
|
|
|
73
95
|
* @param ur - The result UR from the device.
|
|
74
96
|
* @returns The signature string in hexadecimal format.
|
|
75
97
|
*/
|
|
76
|
-
public parseSignature(ur: UR)
|
|
98
|
+
public parseSignature(ur: UR) {
|
|
77
99
|
const signature = TronSignature.fromCBOR(ur.cbor);
|
|
78
|
-
|
|
100
|
+
const signatureBuffer = signature.getSignature();
|
|
101
|
+
const r = signatureBuffer.slice(0, 32).toString('hex');
|
|
102
|
+
const s = signatureBuffer.slice(32, 64).toString('hex');
|
|
103
|
+
const v = signatureBuffer.slice(64).toString('hex');
|
|
104
|
+
return {
|
|
105
|
+
r,
|
|
106
|
+
s,
|
|
107
|
+
v,
|
|
108
|
+
};
|
|
79
109
|
};
|
|
80
110
|
}
|
|
81
111
|
|