@onekeyfe/hd-core 0.2.3 → 0.2.5
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/api/xrp/XrpGetAddress.d.ts +2 -5
- package/dist/api/xrp/XrpGetAddress.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +29 -10
- package/dist/types/api/xrpGetAddress.d.ts +2 -2
- package/dist/types/api/xrpGetAddress.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/xrp/XrpGetAddress.ts +40 -11
- package/src/types/api/xrpGetAddress.ts +2 -2
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { XrpAddress } from '../../types/api/xrpGetAddress';
|
|
1
2
|
import { BaseMethod } from '../BaseMethod';
|
|
2
3
|
export default class XrpGetAddress extends BaseMethod<{
|
|
3
4
|
address_n: number[];
|
|
@@ -10,10 +11,6 @@ export default class XrpGetAddress extends BaseMethod<{
|
|
|
10
11
|
min: string;
|
|
11
12
|
};
|
|
12
13
|
};
|
|
13
|
-
run(): Promise<
|
|
14
|
-
path: string;
|
|
15
|
-
publicKey: string;
|
|
16
|
-
address: string;
|
|
17
|
-
}[]>;
|
|
14
|
+
run(): Promise<XrpAddress | XrpAddress[]>;
|
|
18
15
|
}
|
|
19
16
|
//# sourceMappingURL=XrpGetAddress.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"XrpGetAddress.d.ts","sourceRoot":"","sources":["../../../src/api/xrp/XrpGetAddress.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"XrpGetAddress.d.ts","sourceRoot":"","sources":["../../../src/api/xrp/XrpGetAddress.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAuB,MAAM,+BAA+B,CAAC;AAEhF,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAI3C,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,UAAU,CACnD;IACE,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,YAAY,EAAE,OAAO,CAAC;CACvB,EAAE,CACJ;IACC,SAAS,UAAS;IAElB,IAAI;IA2BJ,eAAe;;;;;IAQT,GAAG;CAyCV"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1144,14 +1144,14 @@ declare function cosmosSignTransaction(connectId: string, deviceId: string, para
|
|
|
1144
1144
|
|
|
1145
1145
|
declare type XrpAddress = {
|
|
1146
1146
|
path: string;
|
|
1147
|
-
publicKey
|
|
1147
|
+
publicKey?: string;
|
|
1148
1148
|
address: string;
|
|
1149
1149
|
};
|
|
1150
1150
|
declare type XrpGetAddressParams = {
|
|
1151
1151
|
path: string | number[];
|
|
1152
1152
|
showOnOneKey?: boolean;
|
|
1153
1153
|
};
|
|
1154
|
-
declare function xrpGetAddress(connectId: string, deviceId: string, params: CommonParams & XrpGetAddressParams): Response<XrpAddress
|
|
1154
|
+
declare function xrpGetAddress(connectId: string, deviceId: string, params: CommonParams & XrpGetAddressParams): Response<XrpAddress>;
|
|
1155
1155
|
declare function xrpGetAddress(connectId: string, deviceId: string, params: CommonParams & {
|
|
1156
1156
|
bundle?: XrpGetAddressParams[];
|
|
1157
1157
|
}): Response<XrpAddress[]>;
|
package/dist/index.js
CHANGED
|
@@ -16078,17 +16078,36 @@ class XrpGetAddress$1 extends BaseMethod {
|
|
|
16078
16078
|
};
|
|
16079
16079
|
}
|
|
16080
16080
|
run() {
|
|
16081
|
+
var _a, _b, _c;
|
|
16081
16082
|
return __awaiter(this, void 0, void 0, function* () {
|
|
16082
|
-
|
|
16083
|
-
|
|
16084
|
-
|
|
16085
|
-
|
|
16086
|
-
|
|
16087
|
-
|
|
16088
|
-
|
|
16089
|
-
|
|
16090
|
-
|
|
16091
|
-
|
|
16083
|
+
if (this.hasBundle && supportBatchPublicKey((_a = this.device) === null || _a === void 0 ? void 0 : _a.features)) {
|
|
16084
|
+
const res = yield this.device.commands.typedCall('BatchGetPublickeys', 'EcdsaPublicKeys', {
|
|
16085
|
+
paths: this.params,
|
|
16086
|
+
ecdsa_curve_name: 'secp256k1',
|
|
16087
|
+
});
|
|
16088
|
+
const result = res.message.public_keys.map((publicKey, index) => ({
|
|
16089
|
+
path: serializedPath(this.params[index].address_n),
|
|
16090
|
+
publicKey,
|
|
16091
|
+
address: rippleKeypairs.deriveAddress(publicKey),
|
|
16092
|
+
}));
|
|
16093
|
+
return Promise.resolve(result);
|
|
16094
|
+
}
|
|
16095
|
+
const responses = [];
|
|
16096
|
+
for (let i = 0; i < this.params.length; i++) {
|
|
16097
|
+
const param = this.params[i];
|
|
16098
|
+
const res = yield this.device.commands.typedCall('RippleGetAddress', 'RippleAddress', Object.assign({}, param));
|
|
16099
|
+
const publicKey = yield this.device.commands.typedCall('BatchGetPublickeys', 'EcdsaPublicKeys', {
|
|
16100
|
+
paths: [{ address_n: param.address_n }],
|
|
16101
|
+
ecdsa_curve_name: 'secp256k1',
|
|
16102
|
+
});
|
|
16103
|
+
const { address } = res.message;
|
|
16104
|
+
responses.push({
|
|
16105
|
+
path: serializedPath(param.address_n),
|
|
16106
|
+
address,
|
|
16107
|
+
publicKey: (_c = (_b = publicKey.message) === null || _b === void 0 ? void 0 : _b.public_keys) === null || _c === void 0 ? void 0 : _c[0],
|
|
16108
|
+
});
|
|
16109
|
+
}
|
|
16110
|
+
return Promise.resolve(this.hasBundle ? responses : responses[0]);
|
|
16092
16111
|
});
|
|
16093
16112
|
}
|
|
16094
16113
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { CommonParams, Response } from '../params';
|
|
2
2
|
export declare type XrpAddress = {
|
|
3
3
|
path: string;
|
|
4
|
-
publicKey
|
|
4
|
+
publicKey?: string;
|
|
5
5
|
address: string;
|
|
6
6
|
};
|
|
7
7
|
export declare type XrpGetAddressParams = {
|
|
8
8
|
path: string | number[];
|
|
9
9
|
showOnOneKey?: boolean;
|
|
10
10
|
};
|
|
11
|
-
export declare function xrpGetAddress(connectId: string, deviceId: string, params: CommonParams & XrpGetAddressParams): Response<XrpAddress
|
|
11
|
+
export declare function xrpGetAddress(connectId: string, deviceId: string, params: CommonParams & XrpGetAddressParams): Response<XrpAddress>;
|
|
12
12
|
export declare function xrpGetAddress(connectId: string, deviceId: string, params: CommonParams & {
|
|
13
13
|
bundle?: XrpGetAddressParams[];
|
|
14
14
|
}): Response<XrpAddress[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xrpGetAddress.d.ts","sourceRoot":"","sources":["../../../src/types/api/xrpGetAddress.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAExD,oBAAY,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"xrpGetAddress.d.ts","sourceRoot":"","sources":["../../../src/types/api/xrpGetAddress.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAExD,oBAAY,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,oBAAY,mBAAmB,GAAG;IAChC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACxB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,aAAa,CACnC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,YAAY,GAAG,mBAAmB,GACzC,QAAQ,CAAC,UAAU,CAAC,CAAC;AAExB,MAAM,CAAC,OAAO,UAAU,aAAa,CACnC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,YAAY,GAAG;IAAE,MAAM,CAAC,EAAE,mBAAmB,EAAE,CAAA;CAAE,GACxD,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-core",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"author": "OneKey",
|
|
6
6
|
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"url": "https://github.com/OneKeyHQ/hardware-js-sdk/issues"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@onekeyfe/hd-shared": "^0.2.
|
|
28
|
-
"@onekeyfe/hd-transport": "^0.2.
|
|
27
|
+
"@onekeyfe/hd-shared": "^0.2.5",
|
|
28
|
+
"@onekeyfe/hd-transport": "^0.2.5",
|
|
29
29
|
"axios": "^0.27.2",
|
|
30
30
|
"bignumber.js": "^9.0.2",
|
|
31
31
|
"jszip": "^3.10.1",
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"@types/semver": "^7.3.9",
|
|
43
43
|
"ripple-keypairs": "^1.1.4"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "05ae2785be37f8d157de5f386010caa2f58335c3"
|
|
46
46
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { deriveAddress } from 'ripple-keypairs';
|
|
2
2
|
import { UI_REQUEST } from '../../constants/ui-request';
|
|
3
|
-
import { XrpGetAddressParams } from '../../types/api/xrpGetAddress';
|
|
3
|
+
import { XrpAddress, XrpGetAddressParams } from '../../types/api/xrpGetAddress';
|
|
4
|
+
import { supportBatchPublicKey } from '../../utils/deviceFeaturesUtils';
|
|
4
5
|
import { BaseMethod } from '../BaseMethod';
|
|
5
6
|
import { validateParams } from '../helpers/paramsValidator';
|
|
6
7
|
import { serializedPath, validatePath } from '../helpers/pathUtils';
|
|
@@ -49,16 +50,44 @@ export default class XrpGetAddress extends BaseMethod<
|
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
async run() {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
53
|
+
if (this.hasBundle && supportBatchPublicKey(this.device?.features)) {
|
|
54
|
+
const res = await this.device.commands.typedCall('BatchGetPublickeys', 'EcdsaPublicKeys', {
|
|
55
|
+
paths: this.params,
|
|
56
|
+
ecdsa_curve_name: 'secp256k1',
|
|
57
|
+
});
|
|
58
|
+
const result = res.message.public_keys.map((publicKey: string, index: number) => ({
|
|
59
|
+
path: serializedPath((this.params as unknown as any[])[index].address_n),
|
|
60
|
+
publicKey,
|
|
61
|
+
address: deriveAddress(publicKey),
|
|
62
|
+
}));
|
|
63
|
+
return Promise.resolve(result);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const responses: XrpAddress[] = [];
|
|
67
|
+
for (let i = 0; i < this.params.length; i++) {
|
|
68
|
+
const param = this.params[i];
|
|
69
|
+
|
|
70
|
+
const res = await this.device.commands.typedCall('RippleGetAddress', 'RippleAddress', {
|
|
71
|
+
...param,
|
|
72
|
+
});
|
|
73
|
+
const publicKey = await this.device.commands.typedCall(
|
|
74
|
+
'BatchGetPublickeys',
|
|
75
|
+
'EcdsaPublicKeys',
|
|
76
|
+
{
|
|
77
|
+
paths: [{ address_n: param.address_n }],
|
|
78
|
+
ecdsa_curve_name: 'secp256k1',
|
|
79
|
+
}
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
const { address } = res.message;
|
|
83
|
+
|
|
84
|
+
responses.push({
|
|
85
|
+
path: serializedPath(param.address_n),
|
|
86
|
+
address,
|
|
87
|
+
publicKey: publicKey.message?.public_keys?.[0],
|
|
88
|
+
});
|
|
89
|
+
}
|
|
61
90
|
|
|
62
|
-
return responses;
|
|
91
|
+
return Promise.resolve(this.hasBundle ? responses : responses[0]);
|
|
63
92
|
}
|
|
64
93
|
}
|
|
@@ -2,7 +2,7 @@ import type { CommonParams, Response } from '../params';
|
|
|
2
2
|
|
|
3
3
|
export type XrpAddress = {
|
|
4
4
|
path: string;
|
|
5
|
-
publicKey
|
|
5
|
+
publicKey?: string;
|
|
6
6
|
address: string;
|
|
7
7
|
};
|
|
8
8
|
|
|
@@ -15,7 +15,7 @@ export declare function xrpGetAddress(
|
|
|
15
15
|
connectId: string,
|
|
16
16
|
deviceId: string,
|
|
17
17
|
params: CommonParams & XrpGetAddressParams
|
|
18
|
-
): Response<XrpAddress
|
|
18
|
+
): Response<XrpAddress>;
|
|
19
19
|
|
|
20
20
|
export declare function xrpGetAddress(
|
|
21
21
|
connectId: string,
|