@onekeyfe/hd-core 0.2.3 → 0.2.4
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 +1 -1
- package/dist/index.js +24 -10
- package/dist/types/api/xrpGetAddress.d.ts +1 -1
- package/dist/types/api/xrpGetAddress.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/xrp/XrpGetAddress.ts +31 -11
- package/src/types/api/xrpGetAddress.ts +1 -1
|
@@ -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;CAgCV"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1144,7 +1144,7 @@ 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 = {
|
package/dist/index.js
CHANGED
|
@@ -16078,17 +16078,31 @@ class XrpGetAddress$1 extends BaseMethod {
|
|
|
16078
16078
|
};
|
|
16079
16079
|
}
|
|
16080
16080
|
run() {
|
|
16081
|
+
var _a;
|
|
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 { address } = res.message;
|
|
16100
|
+
responses.push({
|
|
16101
|
+
path: serializedPath(param.address_n),
|
|
16102
|
+
address,
|
|
16103
|
+
});
|
|
16104
|
+
}
|
|
16105
|
+
return Promise.resolve(this.hasBundle ? responses : responses[0]);
|
|
16092
16106
|
});
|
|
16093
16107
|
}
|
|
16094
16108
|
}
|
|
@@ -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,EAAE,CAAC,CAAC;AAE1B,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.4",
|
|
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.4",
|
|
28
|
+
"@onekeyfe/hd-transport": "^0.2.4",
|
|
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": "8d1af8ca2b9084f8cb7125c4fc98e21a76ecfa84"
|
|
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,35 @@ 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
|
+
|
|
74
|
+
const { address } = res.message;
|
|
75
|
+
|
|
76
|
+
responses.push({
|
|
77
|
+
path: serializedPath(param.address_n),
|
|
78
|
+
address,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
61
81
|
|
|
62
|
-
return responses;
|
|
82
|
+
return Promise.resolve(this.hasBundle ? responses : responses[0]);
|
|
63
83
|
}
|
|
64
84
|
}
|