Skip to content

Commit 1dd206a

Browse files
Fix: optimize Cosmos & Polkadot dApp OK-20488 OK-20489 (#3086)
* fix: cosmos dapp connect * fix: dot dapp interface * fix: kaspa transfer accounts * feat: Support overlay polkadot-js
1 parent b198405 commit 1dd206a

File tree

26 files changed

+500
-304
lines changed

26 files changed

+500
-304
lines changed

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,17 @@
5959
},
6060
"dependencies": {
6161
"@onekeyfe/blockchain-libs": "0.0.48",
62-
"@onekeyfe/cross-inpage-provider-core": "1.1.28",
63-
"@onekeyfe/cross-inpage-provider-errors": "1.1.28",
64-
"@onekeyfe/cross-inpage-provider-injected": "1.1.28",
65-
"@onekeyfe/cross-inpage-provider-types": "1.1.28",
66-
"@onekeyfe/extension-bridge-hosted": "1.1.28",
62+
"@onekeyfe/cross-inpage-provider-core": "1.1.29",
63+
"@onekeyfe/cross-inpage-provider-errors": "1.1.29",
64+
"@onekeyfe/cross-inpage-provider-injected": "1.1.29",
65+
"@onekeyfe/cross-inpage-provider-types": "1.1.29",
66+
"@onekeyfe/extension-bridge-hosted": "1.1.29",
6767
"@onekeyfe/hd-ble-sdk": "0.3.11",
6868
"@onekeyfe/hd-core": "0.3.11",
6969
"@onekeyfe/hd-shared": "0.3.11",
7070
"@onekeyfe/hd-transport": "0.3.11",
7171
"@onekeyfe/hd-web-sdk": "0.3.11",
72-
"@onekeyfe/onekey-cross-webview": "1.1.28",
72+
"@onekeyfe/onekey-cross-webview": "1.1.29",
7373
"@starcoin/starcoin": "2.1.5",
7474
"@web3-react/core": "8.0.35-beta.0",
7575
"@web3-react/empty": "8.0.20-beta.0",

packages/engine/src/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import timelinePerfTrace, {
3737
} from '@onekeyhq/shared/src/perf/timelinePerfTrace';
3838
import platformEnv from '@onekeyhq/shared/src/platformEnv';
3939
import type { Avatar } from '@onekeyhq/shared/src/utils/emojiUtils';
40+
import { getValidUnsignedMessage } from '@onekeyhq/shared/src/utils/messageUtils';
4041
import type { IOneKeyDeviceFeatures } from '@onekeyhq/shared/types';
4142

4243
import { DbApi } from './dbs';
@@ -155,7 +156,6 @@ import type {
155156
IVaultSettings,
156157
} from './vaults/types';
157158
import type { IJsonRpcRequest } from '@onekeyfe/cross-inpage-provider-types';
158-
import { getValidUnsignedMessage } from '@onekeyhq/shared/src/utils/messageUtils';
159159

160160
const updateTokenCache: {
161161
[networkId: string]: boolean;
@@ -637,6 +637,7 @@ class Engine {
637637
coinType: a.coinType,
638638
tokens: [],
639639
address: a.address,
640+
pubKey: get(a, 'pub', ''),
640641
}
641642
: this.getVault({ accountId: a.id, networkId }).then((vault) =>
642643
vault.getOutputAccount().catch((error) => {
@@ -1175,6 +1176,7 @@ class Engine {
11751176
coinType: dbAccount.coinType,
11761177
tokens: [],
11771178
address: dbAccount.address,
1179+
pubKey: get(dbAccount, 'pub', ''),
11781180
};
11791181
}
11801182

packages/engine/src/types/account.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ type DBAccount = DBSimpleAccount | DBUTXOAccount | DBVariantAccount;
4848
type Account = DBBaseAccount & {
4949
tokens: Array<Token>;
5050
address: string;
51+
pubKey?: string;
5152
displayAddress?: string;
5253
xpub?: string; // for btc fork chain
5354
customAddresses?: string; // for btc custom address

packages/engine/src/vaults/VaultBase.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/* eslint max-classes-per-file: "off" */
33

44
import BigNumber from 'bignumber.js';
5-
import { isNil } from 'lodash';
5+
import { get, isNil } from 'lodash';
66

77
import type {
88
BaseClient,
@@ -465,6 +465,7 @@ export abstract class VaultBase extends VaultBaseChainOnly {
465465
tokens: [],
466466
address: dbAccount.address,
467467
template: dbAccount.template,
468+
pubKey: get(dbAccount, 'pub', ''),
468469
};
469470
}
470471

packages/engine/src/vaults/impl/cosmos/Vault.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ export default class Vault extends VaultBase {
179179
)) as DBVariantAccount;
180180

181181
const chainInfo = await this.engine.providerManager.getChainInfoByNetworkId(
182-
this.networkId,
182+
networkId,
183183
);
184184

185185
const address = baseAddressToAddress(

packages/engine/src/vaults/impl/kaspa/KeyringHardware.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,31 @@
11
import { Transaction } from '@kaspa/core-lib';
22
import { bytesToHex } from '@noble/hashes/utils';
33

4+
import { OneKeyHardwareError } from '@onekeyhq/engine/src/errors';
5+
import { slicePathTemplate } from '@onekeyhq/engine/src/managers/derivation';
6+
import { getAccountNameInfoByImpl } from '@onekeyhq/engine/src/managers/impl';
7+
import { AccountType } from '@onekeyhq/engine/src/types/account';
8+
import type { DBSimpleAccount } from '@onekeyhq/engine/src/types/account';
9+
import type { SignedTx, UnsignedTx } from '@onekeyhq/engine/src/types/provider';
10+
import { KeyringHardwareBase } from '@onekeyhq/engine/src/vaults/keyring/KeyringHardwareBase';
11+
import type {
12+
IHardwareGetAddressParams,
13+
IPrepareHardwareAccountsParams,
14+
} from '@onekeyhq/engine/src/vaults/types';
415
import { convertDeviceError } from '@onekeyhq/shared/src/device/deviceErrorUtils';
516
import {
617
IMPL_KASPA as COIN_IMPL,
718
COINTYPE_KASPA as COIN_TYPE,
819
} from '@onekeyhq/shared/src/engine/engineConsts';
920
import debugLogger from '@onekeyhq/shared/src/logger/debugLogger';
1021

11-
import { OneKeyHardwareError } from '../../../errors';
12-
import { slicePathTemplate } from '../../../managers/derivation';
13-
import { getAccountNameInfoByImpl } from '../../../managers/impl';
14-
import { AccountType } from '../../../types/account';
15-
import { KeyringHardwareBase } from '../../keyring/KeyringHardwareBase';
16-
1722
import { SignType, publicKeyFromX } from './sdk';
1823
import {
1924
SignatureType,
2025
SigningMethodType,
2126
toTransaction,
2227
} from './sdk/transaction';
2328

24-
import type { DBSimpleAccount } from '../../../types/account';
25-
import type { SignedTx, UnsignedTx } from '../../../types/provider';
26-
import type {
27-
IHardwareGetAddressParams,
28-
IPrepareHardwareAccountsParams,
29-
} from '../../types';
3029
import type { KaspaSignTransactionParams } from '@onekeyfe/hd-core';
3130

3231
// @ts-ignore

packages/engine/src/vaults/impl/kaspa/KeyringHd.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { bytesToHex, hexToBytes } from '@noble/hashes/utils';
33
import type { ExportedSeedCredential } from '@onekeyhq/engine/src/dbs/base';
44
import { OneKeyInternalError } from '@onekeyhq/engine/src/errors';
55
import { slicePathTemplate } from '@onekeyhq/engine/src/managers/derivation';
6+
import { getAccountNameInfoByImpl } from '@onekeyhq/engine/src/managers/impl';
67
import { Signer } from '@onekeyhq/engine/src/proxy';
78
import { batchGetPublicKeys } from '@onekeyhq/engine/src/secret';
89
import { AccountType } from '@onekeyhq/engine/src/types/account';
@@ -20,8 +21,6 @@ import {
2021
} from '@onekeyhq/shared/src/engine/engineConsts';
2122
import debugLogger from '@onekeyhq/shared/src/logger/debugLogger';
2223

23-
import { getAccountNameInfoByImpl } from '../../../managers/impl';
24-
2524
import {
2625
addressFromPublicKey,
2726
privateKeyFromOriginPrivateKey,

packages/engine/src/vaults/impl/kaspa/KeyringImported.ts

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
11
import { bytesToHex, hexToBytes } from '@noble/hashes/utils';
22

3+
import { OneKeyInternalError } from '@onekeyhq/engine/src/errors';
4+
import { Signer } from '@onekeyhq/engine/src/proxy';
5+
import { secp256k1 } from '@onekeyhq/engine/src/secret/curves';
6+
import { AccountType } from '@onekeyhq/engine/src/types/account';
7+
import type { DBSimpleAccount } from '@onekeyhq/engine/src/types/account';
8+
import type { UnsignedTx } from '@onekeyhq/engine/src/types/provider';
9+
import { KeyringImportedBase } from '@onekeyhq/engine/src/vaults/keyring/KeyringImportedBase';
10+
import type {
11+
IPrepareImportedAccountsParams,
12+
ISignCredentialOptions,
13+
SignedTxResult,
14+
} from '@onekeyhq/engine/src/vaults/types';
315
import { COINTYPE_KASPA as COIN_TYPE } from '@onekeyhq/shared/src/engine/engineConsts';
416
import debugLogger from '@onekeyhq/shared/src/logger/debugLogger';
517

6-
import { OneKeyInternalError } from '../../../errors';
7-
import { Signer } from '../../../proxy';
8-
import { secp256k1 } from '../../../secret/curves';
9-
import { AccountType } from '../../../types/account';
10-
import { KeyringImportedBase } from '../../keyring/KeyringImportedBase';
11-
1218
import {
1319
addressFromPublicKey,
1420
privateKeyFromOriginPrivateKey,
1521
publicKeyFromOriginPubkey,
1622
} from './sdk';
1723
import { signTransaction, toTransaction } from './sdk/transaction';
1824

19-
import type { DBSimpleAccount } from '../../../types/account';
20-
import type { UnsignedTx } from '../../../types/provider';
21-
import type {
22-
IPrepareImportedAccountsParams,
23-
ISignCredentialOptions,
24-
SignedTxResult,
25-
} from '../../types';
2625
import type { PrivateKey } from '@kaspa/core-lib';
2726

2827
// @ts-ignore

packages/engine/src/vaults/impl/kaspa/KeyringWatching.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1+
import { InvalidAddress } from '@onekeyhq/engine/src/errors';
2+
import { AccountType } from '@onekeyhq/engine/src/types/account';
3+
import type { DBSimpleAccount } from '@onekeyhq/engine/src/types/account';
4+
import { KeyringWatchingBase } from '@onekeyhq/engine/src/vaults/keyring/KeyringWatchingBase';
5+
import type { IPrepareWatchingAccountsParams } from '@onekeyhq/engine/src/vaults/types';
16
import { COINTYPE_KASPA as COIN_TYPE } from '@onekeyhq/shared/src/engine/engineConsts';
27

3-
import { InvalidAddress } from '../../../errors';
4-
import { AccountType } from '../../../types/account';
5-
import { KeyringWatchingBase } from '../../keyring/KeyringWatchingBase';
6-
7-
import type { DBSimpleAccount } from '../../../types/account';
8-
import type { IPrepareWatchingAccountsParams } from '../../types';
9-
108
// @ts-ignore
119
export class KeyringWatching extends KeyringWatchingBase {
1210
override async prepareAccounts(

packages/engine/src/vaults/impl/kaspa/Vault.ts

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,37 @@ import BigNumber from 'bignumber.js';
44
import { groupBy } from 'lodash';
55
import memoizee from 'memoizee';
66

7+
import {
8+
InvalidAddress,
9+
OneKeyInternalError,
10+
} from '@onekeyhq/engine/src/errors';
11+
import { decrypt } from '@onekeyhq/engine/src/secret/encryptors/aes256';
712
import type { DBSimpleAccount } from '@onekeyhq/engine/src/types/account';
8-
import { getTimeDurationMs } from '@onekeyhq/kit/src/utils/helper';
9-
10-
import { InvalidAddress, OneKeyInternalError } from '../../../errors';
11-
import { decrypt } from '../../../secret/encryptors/aes256';
12-
import { TransactionStatus } from '../../../types/provider';
13+
import { TransactionStatus } from '@onekeyhq/engine/src/types/provider';
14+
import type { KeyringSoftwareBase } from '@onekeyhq/engine/src/vaults/keyring/KeyringSoftwareBase';
1315
import {
1416
IDecodedTxActionType,
1517
IDecodedTxDirection,
1618
IDecodedTxStatus,
1719
IEncodedTxUpdateType,
18-
} from '../../types';
19-
import { convertFeeValueToGwei } from '../../utils/feeInfoUtils';
20-
import { VaultBase } from '../../VaultBase';
20+
} from '@onekeyhq/engine/src/vaults/types';
21+
import type {
22+
IDecodedTx,
23+
IDecodedTxActionNativeTransfer,
24+
IDecodedTxLegacy,
25+
IEncodedTxUpdateOptions,
26+
IEncodedTxUpdatePayloadTransfer,
27+
IFeeInfo,
28+
IFeeInfoUnit,
29+
IHistoryTx,
30+
ISignedTxPro,
31+
ITransferInfo,
32+
IUnsignedTxPro,
33+
} from '@onekeyhq/engine/src/vaults/types';
34+
import type { TxInput } from '@onekeyhq/engine/src/vaults/utils/btcForkChain/types';
35+
import { convertFeeValueToGwei } from '@onekeyhq/engine/src/vaults/utils/feeInfoUtils';
36+
import { VaultBase } from '@onekeyhq/engine/src/vaults/VaultBase';
37+
import { getTimeDurationMs } from '@onekeyhq/kit/src/utils/helper';
2138

2239
import { KeyringHardware } from './KeyringHardware';
2340
import { KeyringHd } from './KeyringHd';
@@ -39,21 +56,6 @@ import {
3956
import { toTransaction } from './sdk/transaction';
4057
import settings from './settings';
4158

42-
import type { KeyringSoftwareBase } from '../../keyring/KeyringSoftwareBase';
43-
import type {
44-
IDecodedTx,
45-
IDecodedTxActionNativeTransfer,
46-
IDecodedTxLegacy,
47-
IEncodedTxUpdateOptions,
48-
IEncodedTxUpdatePayloadTransfer,
49-
IFeeInfo,
50-
IFeeInfoUnit,
51-
IHistoryTx,
52-
ISignedTxPro,
53-
ITransferInfo,
54-
IUnsignedTxPro,
55-
} from '../../types';
56-
import type { TxInput } from '../../utils/btcForkChain/types';
5759
import type { IEncodedTxKaspa } from './types';
5860

5961
// @ts-ignore

0 commit comments

Comments
 (0)