Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"workspaces": {
"packages": [
"packages/*",
"packages/connect-examples/shared-constants",
"packages/connect-examples/expo-example",
"packages/connect-examples/electron-example",
"packages/connect-examples/expo-playground"
Expand Down Expand Up @@ -79,15 +78,16 @@
"@rollup/plugin-babel": "^5.3.1",
"@rollup/plugin-commonjs": "^22.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^16.0.3",
"@rollup/plugin-typescript": "^8.3.2",
"@types/bchaddrjs": "^0.4.3",
"@types/jest": "^27.5.1",
"@types/node": "^18.18.8",
"@types/shelljs": "^0.8.11",
"electron-builder": "^24.9.1",
"babel-jest": "^28.1.3",
"babel-loader": "^8.2.5",
"cross-env": "^7.0.3",
"electron-builder": "^24.9.1",
"eslint": "^8.4.1",
"eslint-config-wesbos": "3.2.3",
"eslint-plugin-jest": "^26.6.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/connect-examples/expo-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"@tamagui/toast": "1.90.2",
"@ton/core": "^0.57.0",
"asyncstorage-down": "^4.2.0",
"axios": "1.12.2",
"bchaddrjs": "^0.5.2",
"bitcoinjs-lib": "^6.1.5",
"bn.js": "^5.2.1",
Expand Down Expand Up @@ -75,15 +76,14 @@
"react-native-screens": "~3.29.0",
"react-native-svg": "^14.1.0",
"react-native-web": "~0.19.10",
"ripple-keypairs": "^1.1.4",
"rlp": "^3.0.0",
"stackblur-canvas": "^2.7.0",
"stream-browserify": "^3.0.0",
"tamagui": "^1.90.2",
"text-encoding": "^0.7.0",
"tonweb": "^0.0.66",
"varint": "^6.0.0",
"xrpl": "^4.0.0"
"ripple-address-codec": "^5.0.0"
},
"devDependencies": {
"@babel/core": "^7.20.0",
Expand Down
33 changes: 33 additions & 0 deletions packages/connect-examples/expo-example/shim-axios.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Axios wrapper to fix module.exports.default for rollup compatibility
// eslint-disable-next-line @typescript-eslint/no-var-requires
const axios = require('axios');

// Create a proper wrapper that satisfies rollup's _interopDefaultLegacy expectations
// The compiled code uses: axios__default["default"].interceptors.request.use()
// So we need to ensure that when webpack resolves this, it has the right structure

// Ensure axios has a .default property pointing to itself
if (!axios.default) {
axios.default = axios;
}

// Also ensure interceptors exist
if (!axios.interceptors) {
// This shouldn't happen, but just in case, create a mock
axios.interceptors = {
request: {
use: fn => {
console.warn('axios.interceptors.request.use mock called');
return 0;
},
},
response: {
use: fn => {
console.warn('axios.interceptors.response.use mock called');
return 0;
},
},
};
}

module.exports = axios;
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// eslint-disable-next-line import/no-relative-packages
import { getConnectSrc } from '@onekey-internal/shared-constants';

export const CONNECT_SRC = getConnectSrc();
export const CONNECT_SRC = process.env.CONNECT_SRC || `https://jssdk.onekey.so/1.1.17/`;
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
/* eslint-disable no-bitwise */
import type { Success, Unsuccessful } from '@onekeyfe/hd-core';
import { bytesToHex } from '@noble/hashes/utils';
import { deriveAddress } from 'xrpl';
import { bytesToHex, hexToBytes } from '@noble/hashes/utils';
import { encodeAccountID } from 'ripple-address-codec';
import { ripemd160 } from '@noble/hashes/ripemd160';
import { sha256 } from '@noble/hashes/sha256';
import { deriveKeyPairWithPath, mnemonicToSeed } from '../helper';

function publicKeyToAddress(publicKey: Uint8Array): string {
const pub = bytesToHex(publicKey).toUpperCase();
return deriveAddress(pub);
return encodeAccountID(ripemd160(sha256(hexToBytes(pub)))).toString();
}

/**
Expand Down
7 changes: 7 additions & 0 deletions packages/connect-examples/expo-example/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ module.exports = async function (env, argv) {
});
});

// Force axios to use our wrapper which ensures .default exists
config.resolve.alias = {
...config.resolve.alias,
// Force all axios imports to use our wrapper (no $ to match all imports including from node_modules)
axios: require.resolve('./shim-axios.js'),
};

// 保持其他配置不变
config.resolve.fallback = {
crypto: require.resolve('./shim/crypto'),
Expand Down
1 change: 0 additions & 1 deletion packages/connect-examples/expo-playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
"react-router-dom": "^7.6.2",
"reactflow": "^11.11.4",
"rehype-highlight": "^7.0.2",
"ripple-keypairs": "^2.0.0",
"stream-browserify": "^3.0.0",
"stream-http": "^3.2.0",
"string_decoder": "^1.3.0",
Expand Down
12 changes: 0 additions & 12 deletions packages/connect-examples/shared-constants/constants.js

This file was deleted.

10 changes: 0 additions & 10 deletions packages/connect-examples/shared-constants/package.json

This file was deleted.

6 changes: 2 additions & 4 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,13 @@
"semver": "^7.3.7"
},
"peerDependencies": {
"@noble/hashes": "^1.1.3",
"ripple-keypairs": "^1.3.1"
"@noble/hashes": "^1.1.3"
},
"devDependencies": {
"@noble/hashes": "^1.1.3",
"@types/parse-uri": "^1.0.0",
"@types/semver": "^7.3.9",
"@types/w3c-web-usb": "^1.0.10",
"@types/web-bluetooth": "^0.0.21",
"ripple-keypairs": "^1.3.1"
"@types/web-bluetooth": "^0.0.21"
}
}
19 changes: 0 additions & 19 deletions packages/core/src/api/xrp/XrpGetAddress.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import { deriveAddress } from 'ripple-keypairs';
import { UI_REQUEST } from '../../constants/ui-request';
import { XrpAddress, XrpGetAddressParams } from '../../types/api/xrpGetAddress';
import { supportBatchPublicKey } from '../../utils/deviceFeaturesUtils';
import { BaseMethod } from '../BaseMethod';
import { validateParams, validateResult } from '../helpers/paramsValidator';
import { serializedPath, validatePath } from '../helpers/pathUtils';
import { batchGetPublickeys } from '../helpers/batchGetPublickeys';

export default class XrpGetAddress extends BaseMethod<
{
Expand Down Expand Up @@ -57,22 +54,6 @@ export default class XrpGetAddress extends BaseMethod<
}

async run() {
if (this.hasBundle && supportBatchPublicKey(this.device?.features) && !this.shouldConfirm) {
const res = await batchGetPublickeys(this.device, this.params, 'secp256k1', 144);
const result = res.public_keys.map((publicKey: string, index: number) => ({
path: serializedPath((this.params as unknown as any[])[index].address_n),
address: deriveAddress(publicKey),
publicKey,
pub: publicKey,
}));

validateResult(result, ['address', 'publicKey'], {
expectedLength: this.params.length,
});

return Promise.resolve(result);
}

const responses: XrpAddress[] = [];
for (let i = 0; i < this.params.length; i++) {
const param = this.params[i];
Expand Down
Loading
Loading