Skip to content

Commit 95110e5

Browse files
chore: update dependencies version (#534)
* chore: update dependencies version * fix: polkadot address * fix: aplha address
1 parent dbf5d29 commit 95110e5

File tree

9 files changed

+113
-30
lines changed

9 files changed

+113
-30
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* OneKey Hardware SDK Connect Source Configuration
3+
*
4+
* Environment-based configuration for SDK connection source:
5+
* - Development: Uses CONNECT_SRC environment variable (typically https://localhost:8087)
6+
* - Production: Falls back to official CDN with current package version
7+
*
8+
* Usage in package.json scripts:
9+
* - "dev": "CONNECT_SRC=https://localhost:8087 webpack serve --mode=development"
10+
* - "start": "webpack serve --mode=development" (uses CDN)
11+
*/
12+
export const getConnectSrc = () => process.env.CONNECT_SRC || `https://jssdk.onekey.so/1.1.3/`;

packages/connect-examples/expo-example/src/components/BaseTestRunner/useRunnerTest.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,17 @@ type RunnerConfig<T> = {
7171
payload: Unsuccessful | Success<any>;
7272
skipVerify?: boolean;
7373
}>;
74+
preCheckResponse?: (
75+
method: string,
76+
requestParams: any,
77+
item: TestCaseDataWithKey<T>,
78+
itemIndex: number,
79+
res: Unsuccessful | Success<any>
80+
) => Promise<{
81+
error: string | undefined;
82+
verifyState?: VerifyState;
83+
ext?: any;
84+
}>;
7485
processResponse: (
7586
response: any,
7687
item: TestCaseDataWithKey<T>,
@@ -95,6 +106,7 @@ export function useRunnerTest<T>(config: RunnerConfig<T>) {
95106
prepareRunnerTestCaseDelay,
96107
generateRequestParams,
97108
processRequest,
109+
preCheckResponse,
98110
processResponse,
99111
removeHardwareListener,
100112
processRunnerDone,
@@ -313,7 +325,19 @@ export function useRunnerTest<T>(config: RunnerConfig<T>) {
313325
let error: string | undefined = '';
314326
let ext: any;
315327

316-
if (!res.success && !skipVerify) {
328+
if (preCheckResponse) {
329+
const result = await preCheckResponse(method, requestParams, item, itemIndex, res);
330+
error = result.error;
331+
ext = result.ext;
332+
333+
if (result.verifyState) {
334+
verifyState = result.verifyState;
335+
} else if (isEmpty(error)) {
336+
verifyState = 'success';
337+
} else {
338+
verifyState = 'fail';
339+
}
340+
} else if (!res.success && !skipVerify) {
317341
if (res.payload?.code === 802 || res.payload?.code === 803) {
318342
verifyState = 'skip';
319343
} else {
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import packageJson from '../../package.json';
1+
// eslint-disable-next-line import/no-relative-packages
2+
import { getConnectSrc } from '../../../constants';
23

3-
export const CONNECT_SRC =
4-
process.env.CONNECT_SRC || `https://jssdk.onekey.so/${packageJson.version}/`;
4+
export const CONNECT_SRC = getConnectSrc();

packages/connect-examples/expo-example/src/testTools/addressTest/MnemonicAddressValidation.tsx

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -387,16 +387,41 @@ function ExecuteView() {
387387
params: requestParams,
388388
});
389389
},
390-
processResponse: (res, item, itemIndex) => {
391-
const response = res as {
392-
path: string;
393-
address: string;
394-
};
390+
preCheckResponse: (method, requestParams, item, itemIndex, res) => {
391+
console.log('preCheckResponse', method, requestParams, item, itemIndex, res);
392+
393+
if (
394+
method === 'alephiumGetAddress' &&
395+
!res.success &&
396+
(res.payload?.code === 416 ||
397+
res.payload?.error?.toLowerCase()?.includes('forbidden key path'))
398+
) {
399+
return Promise.resolve({
400+
verifyState: 'skip',
401+
error: undefined,
402+
});
403+
}
404+
405+
if (!res.success) {
406+
if (res.payload?.code === 802 || res.payload?.code === 803) {
407+
return Promise.resolve({
408+
verifyState: 'skip',
409+
error: undefined,
410+
});
411+
}
412+
return Promise.resolve({
413+
verifyState: 'fail',
414+
error: res.payload?.error,
415+
});
416+
}
395417

396418
const error = '';
419+
const response = res.payload as {
420+
address: string;
421+
trackingKey?: string;
422+
};
397423

398424
const responseAddress =
399-
// @ts-expect-error
400425
response.address?.toLowerCase() || response.trackingKey?.toLowerCase();
401426
if (item.address?.toLowerCase() !== responseAddress) {
402427
return Promise.resolve({
@@ -408,6 +433,10 @@ function ExecuteView() {
408433
error,
409434
});
410435
},
436+
processResponse: () =>
437+
Promise.resolve({
438+
error: undefined,
439+
}),
411440
removeHardwareListener: sdk => {
412441
if (hardwareUiEventListener) {
413442
sdk.off(UI_EVENT, hardwareUiEventListener);

packages/connect-examples/expo-example/src/utils/mockDevice/method/polkadotGetAddress.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
/* eslint-disable no-bitwise */
12
import { PolkadotGetAddressParams } from '@onekeyfe/hd-core';
23
import { hdLedger, encodeAddress } from '@polkadot/util-crypto';
3-
import { mnemonicToSeed, deriveKeyPairWithPath } from '../helper';
4+
import { deriveKeyPairWithPath } from '../helper';
45

56
/**
67
* 抽离的核心逻辑:从 seed 生成 Polkadot 地址
@@ -33,8 +34,7 @@ export function generatePolkadotAddressFromMnemonic(
3334
prefix = 0,
3435
passphrase = ''
3536
): string {
36-
// hdLedger只接受2个参数:mnemonic和path
37-
const secret = hdLedger(mnemonic, path);
37+
const secret = hdLedger(mnemonic, path, passphrase);
3838
return encodeAddress(secret.publicKey, prefix);
3939
}
4040

@@ -53,8 +53,7 @@ export default function polkadotGetAddress(
5353
const pathStr = Array.isArray(path) ? path.join('/') : path;
5454

5555
// 使用抽离的函数,先转换助记词为seed
56-
const seed = mnemonicToSeed(mnemonic, passphrase);
57-
const address = generatePolkadotAddressFromSeed(seed, pathStr, prefix);
56+
const address = generatePolkadotAddressFromMnemonic(mnemonic, pathStr, prefix, passphrase);
5857

5958
return {
6059
success: true,

packages/connect-examples/expo-playground/app/constants/connect.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import packageJson from '../../package.json';
1+
import { getConnectSrc } from '../../../constants';
22

33
/**
44
* OneKey Hardware SDK Connect Source Configuration
@@ -11,5 +11,4 @@ import packageJson from '../../package.json';
1111
* - "dev": "CONNECT_SRC=https://localhost:8087 webpack serve --mode=development"
1212
* - "start": "webpack serve --mode=development" (uses CDN)
1313
*/
14-
export const CONNECT_SRC =
15-
process.env.CONNECT_SRC || `https://jssdk.onekey.so/${packageJson.version}/`;
14+
export const CONNECT_SRC = getConnectSrc();

packages/core/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@
3636
},
3737
"peerDependencies": {
3838
"@noble/hashes": "^1.1.3",
39-
"ripple-keypairs": "^1.1.4"
39+
"ripple-keypairs": "^1.3.1"
4040
},
4141
"devDependencies": {
4242
"@noble/hashes": "^1.1.3",
4343
"@types/parse-uri": "^1.0.0",
4444
"@types/semver": "^7.3.9",
4545
"@types/w3c-web-usb": "^1.0.10",
4646
"@types/web-bluetooth": "^0.0.21",
47-
"ripple-keypairs": "^1.1.4"
47+
"ripple-keypairs": "^1.3.1"
4848
}
4949
}

patches/@polkadot+util-crypto+13.1.1.patch

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
diff --git a/node_modules/@polkadot/util-crypto/cjs/hd/ledger/index.js b/node_modules/@polkadot/util-crypto/cjs/hd/ledger/index.js
2-
index dce3405..f0e8fe3 100644
2+
index dce3405..5f3cb20 100644
33
--- a/node_modules/@polkadot/util-crypto/cjs/hd/ledger/index.js
44
+++ b/node_modules/@polkadot/util-crypto/cjs/hd/ledger/index.js
5-
@@ -6,17 +6,15 @@ const index_js_2 = require("../../mnemonic/index.js");
5+
@@ -6,17 +6,12 @@ const index_js_2 = require("../../mnemonic/index.js");
66
const validatePath_js_1 = require("../validatePath.js");
77
const derivePrivate_js_1 = require("./derivePrivate.js");
88
const master_js_1 = require("./master.js");
@@ -18,9 +18,6 @@ index dce3405..f0e8fe3 100644
1818
- const [mnemonic, password] = words.length === 25
1919
- ? [words.slice(0, 24).join(' '), words[24]]
2020
- : [words.join(' '), ''];
21-
+ // if (![12, 24, 25].includes(words.length)) {
22-
+ // throw new Error('Expected a mnemonic with 24 words (or 25 including a password)');
23-
+ // }
2421
+ const [mnemonic, password] = [words.join(' '), passphrase]
2522
if (!(0, index_js_2.mnemonicValidate)(mnemonic)) {
2623
throw new Error('Invalid mnemonic passed to ledger derivation');
@@ -34,10 +31,10 @@ index 691d037..f33849c 100644
3431
-export declare function hdLedger(_mnemonic: string, path: string): Keypair;
3532
+export declare function hdLedger(_mnemonic: string, path: string, passphrase?: string): Keypair;
3633
diff --git a/node_modules/@polkadot/util-crypto/hd/ledger/index.js b/node_modules/@polkadot/util-crypto/hd/ledger/index.js
37-
index 78f557b..2257c6a 100644
34+
index 78f557b..7b88fc4 100644
3835
--- a/node_modules/@polkadot/util-crypto/hd/ledger/index.js
3936
+++ b/node_modules/@polkadot/util-crypto/hd/ledger/index.js
40-
@@ -3,17 +3,15 @@ import { mnemonicValidate } from '../../mnemonic/index.js';
37+
@@ -3,17 +3,12 @@ import { mnemonicValidate } from '../../mnemonic/index.js';
4138
import { HARDENED, hdValidatePath } from '../validatePath.js';
4239
import { ledgerDerivePrivate } from './derivePrivate.js';
4340
import { ledgerMaster } from './master.js';
@@ -53,9 +50,6 @@ index 78f557b..2257c6a 100644
5350
- const [mnemonic, password] = words.length === 25
5451
- ? [words.slice(0, 24).join(' '), words[24]]
5552
- : [words.join(' '), ''];
56-
+ // if (![12, 24, 25].includes(words.length)) {
57-
+ // throw new Error('Expected a mnemonic with 24 words (or 25 including a password)');
58-
+ // }
5953
+ const [mnemonic, password] = [words.join(' '), passphrase]
6054
if (!mnemonicValidate(mnemonic)) {
6155
throw new Error('Invalid mnemonic passed to ledger derivation');

yarn.lock

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10089,6 +10089,13 @@ base-x@^3.0.2:
1008910089
dependencies:
1009010090
safe-buffer "^5.0.1"
1009110091

10092+
base-x@^3.0.9:
10093+
version "3.0.11"
10094+
resolved "https://registry.yarnpkg.com/base-x/-/base-x-3.0.11.tgz#40d80e2a1aeacba29792ccc6c5354806421287ff"
10095+
integrity sha512-xz7wQ8xDhdyP7tQxwdteLYeFfS68tSMNCZ/Y37WJ4bhGfKPpqEIlmIyueQHqOyoPhE6xNUqjzRr8ra0eF9VRvA==
10096+
dependencies:
10097+
safe-buffer "^5.0.1"
10098+
1009210099
base64-js@*, base64-js@^1.2.3, base64-js@^1.3.0, base64-js@^1.3.1, base64-js@^1.5.1:
1009310100
version "1.5.1"
1009410101
resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a"
@@ -22536,6 +22543,14 @@ ripple-address-codec@^4.2.4:
2253622543
base-x "3.0.9"
2253722544
create-hash "^1.1.2"
2253822545

22546+
ripple-address-codec@^4.3.1:
22547+
version "4.3.1"
22548+
resolved "https://registry.yarnpkg.com/ripple-address-codec/-/ripple-address-codec-4.3.1.tgz#68fbaf646bb8567f70743af7f1ce4479f73efbf6"
22549+
integrity sha512-Qa3+9wKVvpL/xYtT6+wANsn0A1QcC5CT6IMZbRJZ/1lGt7gmwIfsrCuz1X0+LCEO7zgb+3UT1I1dc0k/5dwKQQ==
22550+
dependencies:
22551+
base-x "^3.0.9"
22552+
create-hash "^1.1.2"
22553+
2253922554
ripple-address-codec@^5.0.0:
2254022555
version "5.0.0"
2254122556
resolved "https://registry.yarnpkg.com/ripple-address-codec/-/ripple-address-codec-5.0.0.tgz#97059f7bba6f9ed7a52843de8aa427723fb529f6"
@@ -22564,6 +22579,17 @@ ripple-keypairs@^1.1.4:
2256422579
hash.js "^1.0.3"
2256522580
ripple-address-codec "^4.2.4"
2256622581

22582+
ripple-keypairs@^1.3.1:
22583+
version "1.3.1"
22584+
resolved "https://registry.yarnpkg.com/ripple-keypairs/-/ripple-keypairs-1.3.1.tgz#7fa531df36b138134afb53555a87d7f5eb465b2e"
22585+
integrity sha512-dmPlraWKJciFJxHcoubDahGnoIalG5e/BtV6HNDUs7wLXmtnLMHt6w4ed9R8MTL2zNrVPiIdI/HCtMMo0Tm7JQ==
22586+
dependencies:
22587+
bn.js "^5.1.1"
22588+
brorand "^1.0.5"
22589+
elliptic "^6.5.4"
22590+
hash.js "^1.0.3"
22591+
ripple-address-codec "^4.3.1"
22592+
2256722593
ripple-keypairs@^2.0.0:
2256822594
version "2.0.0"
2256922595
resolved "https://registry.yarnpkg.com/ripple-keypairs/-/ripple-keypairs-2.0.0.tgz#4a1a8142e9a58c07e61b3cc6cfe7317db718d289"

0 commit comments

Comments
 (0)